Class LongProvider
java.lang.Object
org.apache.commons.rng.core.BaseProvider
org.apache.commons.rng.core.source64.LongProvider
- All Implemented Interfaces:
RandomLongSource,RestorableUniformRandomProvider,UniformRandomProvider
- Direct Known Subclasses:
MersenneTwister64,SplitMix64,TwoCmres,XoRoShiRo128Plus,XoRoShiRo128StarStar,XorShift1024Star,XoShiRo256Plus,XoShiRo256StarStar,XoShiRo512Plus,XoShiRo512StarStar
public abstract class LongProvider extends BaseProvider implements RandomLongSource
Base class for all implementations that provide a
long-based
source randomness.-
Constructor Summary
Constructors Constructor Description LongProvider() -
Method Summary
Modifier and Type Method Description protected byte[]getStateInternal()Creates a snapshot of the RNG state.booleannextBoolean()Generates abooleanvalue.voidnextBytes(byte[] bytes)Generatesbytevalues and places them into a user-supplied array.voidnextBytes(byte[] bytes, int start, int len)Generatesbytevalues and places them into a user-supplied array.doublenextDouble()Generates adoublevalue between 0 and 1.floatnextFloat()Generates afloatvalue between 0 and 1.intnextInt()Generates anintvalue.longnextLong()Generates alongvalue.protected voidsetStateInternal(byte[] s)Resets the RNG to the givenstate.Methods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, fillState, fillState, nextInt, nextLong, restoreState, saveState, splitStateInternal, toString
-
Constructor Details
-
LongProvider
public LongProvider()
-
-
Method Details
-
getStateInternal
protected byte[] getStateInternal()Creates a snapshot of the RNG state.- Overrides:
getStateInternalin classBaseProvider- Returns:
- the internal state.
-
setStateInternal
protected void setStateInternal(byte[] s)Resets the RNG to the givenstate.- Overrides:
setStateInternalin classBaseProvider- Parameters:
s- State (previously obtained by a call toBaseProvider.getStateInternal()).- See Also:
BaseProvider.checkStateSize(byte[],int)
-
nextLong
public long nextLong()Generates alongvalue.- Specified by:
nextLongin interfaceUniformRandomProvider- Returns:
- the next random value.
-
nextInt
public int nextInt()Generates anintvalue.- Specified by:
nextIntin interfaceUniformRandomProvider- Returns:
- the next random value.
-
nextDouble
public double nextDouble()Generates adoublevalue between 0 and 1.- Specified by:
nextDoublein interfaceUniformRandomProvider- Returns:
- the next random value between 0 and 1.
-
nextBoolean
public boolean nextBoolean()Generates abooleanvalue.- Specified by:
nextBooleanin interfaceUniformRandomProvider- Returns:
- the next random value.
-
nextFloat
public float nextFloat()Generates afloatvalue between 0 and 1.- Specified by:
nextFloatin interfaceUniformRandomProvider- Returns:
- the next random value between 0 and 1.
-
nextBytes
public void nextBytes(byte[] bytes)Generatesbytevalues and places them into a user-supplied array.The number of random bytes produced is equal to the length of the the byte array.
- Specified by:
nextBytesin interfaceUniformRandomProvider- Parameters:
bytes- Byte array in which to put the random bytes. Cannot benull.
-
nextBytes
public void nextBytes(byte[] bytes, int start, int len)Generatesbytevalues and places them into a user-supplied array.The array is filled with bytes extracted from random integers. This implies that the number of random bytes generated may be larger than the length of the byte array.
- Specified by:
nextBytesin interfaceUniformRandomProvider- Parameters:
bytes- Array in which to put the generated bytes. Cannot benull.start- Index at which to start inserting the generated bytes.len- Number of bytes to insert.
-