public final class RandomStreams extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
RandomStreams.SeededObjectFactory<T>
A factory for creating objects using a seed and a using a source of randomness.
|
| Modifier and Type | Method and Description |
|---|---|
static <T> Stream<T> |
generateWithSeed(long streamSize,
SplittableUniformRandomProvider source,
RandomStreams.SeededObjectFactory<T> factory)
Returns a stream producing the given
streamSize number of new objects
generated using the supplied source of randomness and object factory. |
public static <T> Stream<T> generateWithSeed(long streamSize, SplittableUniformRandomProvider source, RandomStreams.SeededObjectFactory<T> factory)
streamSize number of new objects
generated using the supplied source of randomness and object factory.
A long seed is provided for each object instance using the stream position
and random bits created from the supplied source.
The stream supports parallel execution by splitting the provided source
of randomness. Consequently objects in the same position in the stream created from
a sequential stream may be created from a different source of randomness than a parallel
stream; it is not expected that parallel execution will create the same final
collection of objects.
T - the object typestreamSize - Number of objects to generate.source - A source of randomness used to initialise the new instances; this may
be split to provide a source of randomness across a parallel stream.factory - Factory to create new instances.streamSize.IllegalArgumentException - if streamSize is negative.NullPointerException - if source or factory is null.Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.