Class 
Use 
SUMMARY: NESTED | FIELD | CONSTR | METHOD      DETAIL: FIELD | CONSTR | METHOD
FlexDoc/Javadoc 2.0
Demo Java Doc

java.base / java.util
Class SplittableRandom
java.lang.Object
  java.util.SplittableRandom
All Implemented Interfaces:
RandomGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator

public final class SplittableRandom
extends Object
implements RandomGenerator, RandomGenerator.SplittableGenerator
A generator of uniform pseudorandom values (with period 264) applicable for use in (among other contexts) isolated parallel computations that may generate subtasks. Class SplittableRandom supports methods for producing pseudorandom numbers of type int, long, and double with similar usages as for class Random but differs in the following ways:

Instances of SplittableRandom are not cryptographically secure. Consider instead using SecureRandom in security-sensitive applications. Additionally, default-constructed instances do not use a cryptographically random seed unless the system property java.util.secureRandomSeed is set to true.

Since:
1.8
Author:
Guy Steele, Doug Lea

Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator
Constructor Summary
Creates a new SplittableRandom instance that is likely to generate sequences of values that are statistically independent of those of any other instances in the current program; and may, and typically does, vary across program invocations.
SplittableRandom(long seed)
Creates a new SplittableRandom instance using the specified initial seed.
Method Summary
Returns an effectively unlimited stream of pseudorandom double values from this generator and/or one split from it; each value is between zero (inclusive) and one (exclusive).
doubles(double randomNumberOrigin, double randomNumberBound)
Returns an effectively unlimited stream of pseudorandom double values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
doubles(long streamSize)
Returns a stream producing the given streamSize number of pseudorandom double values from this generator and/or one split from it; each value is between zero (inclusive) and one (exclusive).
doubles(long streamSize, double randomNumberOrigin, double randomNumberBound)
Returns a stream producing the given streamSize number of pseudorandom double values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Returns an effectively unlimited stream of pseudorandom int values from this generator and/or one split from it.
ints(int randomNumberOrigin, int randomNumberBound)
Returns an effectively unlimited stream of pseudorandom int values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
ints(long streamSize)
Returns a stream producing the given streamSize number of pseudorandom int values from this generator and/or one split from it.
ints(long streamSize, int randomNumberOrigin, int randomNumberBound)
Returns a stream producing the given streamSize number of pseudorandom int values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Returns an effectively unlimited stream of pseudorandom long values from this generator and/or one split from it.
longs(long streamSize)
Returns a stream producing the given streamSize number of pseudorandom long values from this generator and/or one split from it.
longs(long randomNumberOrigin, long randomNumberBound)
Returns an effectively unlimited stream of pseudorandom long values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
longs(long streamSize, long randomNumberOrigin, long randomNumberBound)
Returns a stream producing the given streamSize number of pseudorandom long values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
void
nextBytes(byte[] bytes)
Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).
int
Returns a pseudorandomly chosen int value.
long
Returns a pseudorandomly chosen long value.
Constructs and returns a new SplittableRandom instance that shares no mutable state with this instance.
Returns a new pseudorandom number generator, split off from this one, that implements the RandomGenerator and RandomGenerator.SplittableGenerator interfaces.
Returns an effectively unlimited stream of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.
splits(long streamSize)
Returns a stream producing the given streamSize number of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.
Returns a stream producing the given streamSize number of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.
Returns an effectively unlimited stream of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.random.RandomGenerator
getDefault, isDeprecated, nextBoolean, nextDouble, nextDouble, nextDouble, nextExponential, nextFloat, nextFloat, nextFloat, nextGaussian, nextGaussian, nextInt, nextInt, nextLong, nextLong, of
Methods inherited from interface java.util.random.RandomGenerator.SplittableGenerator
rngs, rngs
Constructor Detail
SplittableRandom
public SplittableRandom
(long seed)
Creates a new SplittableRandom instance using the specified initial seed. SplittableRandom instances created with the same seed in the same program generate identical sequences of values.
Parameters:
seed - the initial seed

SplittableRandom
public SplittableRandom
()
Creates a new SplittableRandom instance that is likely to generate sequences of values that are statistically independent of those of any other instances in the current program; and may, and typically does, vary across program invocations.
Method Detail
split
public SplittableRandom split
()
Constructs and returns a new SplittableRandom instance that shares no mutable state with this instance. However, with very high probability, the set of values collectively generated by the two objects has the same statistical properties as if the same quantity of values were generated by a single thread using a single SplittableRandom object. Either or both of the two objects may be further split using the split() method, and the same expected statistical properties apply to the entire set of generators constructed by such recursive splitting.
Specified by:
split in interface RandomGenerator.SplittableGenerator
Returns:
the new SplittableRandom instance

split
public SplittableRandom split
Returns a new pseudorandom number generator, split off from this one, that implements the RandomGenerator and RandomGenerator.SplittableGenerator interfaces.
Specified by:
split in interface RandomGenerator.SplittableGenerator
Parameters:
source - a RandomGenerator.SplittableGenerator instance to be used instead of this one as a source of pseudorandom bits used to initialize the state of the new ones.
Returns:
an object that implements the RandomGenerator and RandomGenerator.SplittableGenerator interfaces
Throws:
NullPointerException - if source is null
Since:
17

nextInt
public int nextInt
()
Description copied from interface: RandomGenerator
Returns a pseudorandomly chosen int value.
Specified by:
nextInt in interface RandomGenerator
Returns:
a pseudorandomly chosen int value

nextLong
public long nextLong
()
Description copied from interface: RandomGenerator
Returns a pseudorandomly chosen long value.
Specified by:
nextLong in interface RandomGenerator
Returns:
a pseudorandomly chosen long value

nextBytes
public void nextBytes
(byte[] bytes)
Fills a user-supplied byte array with generated byte values pseudorandomly chosen uniformly from the range of values between -128 (inclusive) and 127 (inclusive).
Specified by:
nextBytes in interface RandomGenerator
Parameters:
bytes - the byte array to fill with pseudorandom bytes
Throws:
NullPointerException - if bytes is null
Since:
10

splits
()
Returns an effectively unlimited stream of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.

This pseudorandom number generator may be used as a source of pseudorandom bits used to initialize the state the new ones.

Specified by:
splits in interface RandomGenerator.SplittableGenerator
Returns:
a stream of RandomGenerator.SplittableGenerator objects
Since:
17

splits
(long streamSize)
Returns a stream producing the given streamSize number of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.

This pseudorandom number generator may be used as a source of pseudorandom bits used to initialize the state the new ones.

Specified by:
splits in interface RandomGenerator.SplittableGenerator
Parameters:
streamSize - the number of values to generate
Returns:
a stream of RandomGenerator.SplittableGenerator objects
Throws:
IllegalArgumentException - if streamSize is less than zero
Since:
17

splits
Returns an effectively unlimited stream of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.
Specified by:
splits in interface RandomGenerator.SplittableGenerator
Parameters:
source - a RandomGenerator.SplittableGenerator instance to be used instead of this one as a source of pseudorandom bits used to initialize the state of the new ones.
Returns:
a stream of RandomGenerator.SplittableGenerator objects
Throws:
NullPointerException - if source is null
Since:
17

splits
(long streamSize,
 RandomGenerator.SplittableGenerator source)
Returns a stream producing the given streamSize number of new pseudorandom number generators, each of which implements the RandomGenerator.SplittableGenerator interface.
Specified by:
splits in interface RandomGenerator.SplittableGenerator
Parameters:
streamSize - the number of values to generate
source - a RandomGenerator.SplittableGenerator instance to be used instead of this one as a source of pseudorandom bits used to initialize the state of the new ones.
Returns:
a stream of RandomGenerator.SplittableGenerator objects
Throws:
NullPointerException - if source is null
IllegalArgumentException - if streamSize is less than zero
Since:
17

ints
public IntStream ints
(long streamSize)
Returns a stream producing the given streamSize number of pseudorandom int values from this generator and/or one split from it.
Specified by:
ints in interface RandomGenerator
Parameters:
streamSize - the number of values to generate
Returns:
a stream of pseudorandom int values
Throws:
IllegalArgumentException - if streamSize is less than zero

ints
public IntStream ints
()
Returns an effectively unlimited stream of pseudorandom int values from this generator and/or one split from it.
Implementation Note:
This method is implemented to be equivalent to ints(Long.MAX_VALUE).
Specified by:
ints in interface RandomGenerator
Returns:
a stream of pseudorandom int values

ints
public IntStream ints
(long streamSize,
 int randomNumberOrigin,
 int randomNumberBound)
Returns a stream producing the given streamSize number of pseudorandom int values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Specified by:
ints in interface RandomGenerator
Parameters:
streamSize - the number of values to generate
randomNumberOrigin - the origin (inclusive) of each random value
randomNumberBound - the bound (exclusive) of each random value
Returns:
a stream of pseudorandom int values, each with the given origin (inclusive) and bound (exclusive)
Throws:
IllegalArgumentException - if streamSize is less than zero, or randomNumberOrigin is greater than or equal to randomNumberBound

ints
public IntStream ints
(int randomNumberOrigin,
 int randomNumberBound)
Returns an effectively unlimited stream of pseudorandom int values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Implementation Note:
This method is implemented to be equivalent to ints(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).
Specified by:
ints in interface RandomGenerator
Parameters:
randomNumberOrigin - the origin (inclusive) of each random value
randomNumberBound - the bound (exclusive) of each random value
Returns:
a stream of pseudorandom int values, each with the given origin (inclusive) and bound (exclusive)
Throws:
IllegalArgumentException - if randomNumberOrigin is greater than or equal to randomNumberBound

longs
public LongStream longs
(long streamSize)
Returns a stream producing the given streamSize number of pseudorandom long values from this generator and/or one split from it.
Specified by:
longs in interface RandomGenerator
Parameters:
streamSize - the number of values to generate
Returns:
a stream of pseudorandom long values
Throws:
IllegalArgumentException - if streamSize is less than zero

longs
public LongStream longs
()
Returns an effectively unlimited stream of pseudorandom long values from this generator and/or one split from it.
Implementation Note:
This method is implemented to be equivalent to longs(Long.MAX_VALUE).
Specified by:
longs in interface RandomGenerator
Returns:
a stream of pseudorandom long values

longs
public LongStream longs
(long streamSize,
 long randomNumberOrigin,
 long randomNumberBound)
Returns a stream producing the given streamSize number of pseudorandom long values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Specified by:
longs in interface RandomGenerator
Parameters:
streamSize - the number of values to generate
randomNumberOrigin - the origin (inclusive) of each random value
randomNumberBound - the bound (exclusive) of each random value
Returns:
a stream of pseudorandom long values, each with the given origin (inclusive) and bound (exclusive)
Throws:
IllegalArgumentException - if streamSize is less than zero, or randomNumberOrigin is greater than or equal to randomNumberBound

longs
public LongStream longs
(long randomNumberOrigin,
 long randomNumberBound)
Returns an effectively unlimited stream of pseudorandom long values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Implementation Note:
This method is implemented to be equivalent to longs(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).
Specified by:
longs in interface RandomGenerator
Parameters:
randomNumberOrigin - the origin (inclusive) of each random value
randomNumberBound - the bound (exclusive) of each random value
Returns:
a stream of pseudorandom long values, each with the given origin (inclusive) and bound (exclusive)
Throws:
IllegalArgumentException - if randomNumberOrigin is greater than or equal to randomNumberBound

doubles
public DoubleStream doubles
(long streamSize)
Returns a stream producing the given streamSize number of pseudorandom double values from this generator and/or one split from it; each value is between zero (inclusive) and one (exclusive).
Specified by:
doubles in interface RandomGenerator
Parameters:
streamSize - the number of values to generate
Returns:
a stream of double values
Throws:
IllegalArgumentException - if streamSize is less than zero

doubles
public DoubleStream doubles
()
Returns an effectively unlimited stream of pseudorandom double values from this generator and/or one split from it; each value is between zero (inclusive) and one (exclusive).
Implementation Note:
This method is implemented to be equivalent to doubles(Long.MAX_VALUE).
Specified by:
doubles in interface RandomGenerator
Returns:
a stream of pseudorandom double values

doubles
public DoubleStream doubles
(long streamSize,
 double randomNumberOrigin,
 double randomNumberBound)
Returns a stream producing the given streamSize number of pseudorandom double values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Specified by:
doubles in interface RandomGenerator
Parameters:
streamSize - the number of values to generate
randomNumberOrigin - the origin (inclusive) of each random value
randomNumberBound - the bound (exclusive) of each random value
Returns:
a stream of pseudorandom double values, each with the given origin (inclusive) and bound (exclusive)
Throws:
IllegalArgumentException - if streamSize is less than zero, or randomNumberOrigin is greater than or equal to randomNumberBound

doubles
public DoubleStream doubles
(double randomNumberOrigin,
 double randomNumberBound)
Returns an effectively unlimited stream of pseudorandom double values from this generator and/or one split from it; each value conforms to the given origin (inclusive) and bound (exclusive).
Implementation Note:
This method is implemented to be equivalent to doubles(Long.MAX_VALUE, randomNumberOrigin, randomNumberBound).
Specified by:
doubles in interface RandomGenerator
Parameters:
randomNumberOrigin - the origin (inclusive) of each random value
randomNumberBound - the bound (exclusive) of each random value
Returns:
a stream of pseudorandom double values, each with the given origin (inclusive) and bound (exclusive)
Throws:
IllegalArgumentException - if randomNumberOrigin is greater than or equal to randomNumberBound

 Class 
Use 
SUMMARY: NESTED | FIELD | CONSTR | METHOD      DETAIL: FIELD | CONSTR | METHOD
FlexDoc/Javadoc 2.0
Demo Java Doc

Java API documentation generated with FlexDoc/Javadoc 2.0 using JavadocClassic 3.0 template set.
FlexDoc/Javadoc is a template-driven programming tool for rapid development of any Javadoc-based Java API documentation generators (i.e. doclets). If you need to customize your Javadoc without writing a full-blown doclet from scratch, FlexDoc/Javadoc may be the only tool able to help you! Find out more at www.flexdoc.xyz