Class IntProvider
- java.lang.Object
-
- org.apache.commons.rng.core.BaseProvider
-
- org.apache.commons.rng.core.source32.IntProvider
-
- All Implemented Interfaces:
RandomIntSource,RestorableUniformRandomProvider,UniformRandomProvider
- Direct Known Subclasses:
AbstractWell,DotyHumphreySmallFastCounting32,ISAACRandom,JDKRandom,JenkinsSmallFast32,KISSRandom,L32X64Mix,MersenneTwister,MiddleSquareWeylSequence,MultiplyWithCarry256,PcgMcgXshRr32,PcgMcgXshRs32,PcgXshRr32,PcgXshRs32,XoRoShiRo64Star,XoRoShiRo64StarStar,XoShiRo128Plus,XoShiRo128PlusPlus,XoShiRo128StarStar
public abstract class IntProvider extends BaseProvider implements RandomIntSource
Base class for all implementations that provide anint-based source randomness.
-
-
Constructor Summary
Constructors Modifier Constructor Description IntProvider()Creates a new instance.protectedIntProvider(IntProvider source)Creates a new instance copying the state from the source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected byte[]getStateInternal()Creates a snapshot of the RNG state.booleannextBoolean()voidnextBytes(byte[] bytes)voidnextBytes(byte[] bytes, int start, int len)doublenextDouble()intnextInt()longnextLong()protected voidresetCachedState()Reset the cached state used in the default implementation ofnextBoolean().protected voidsetStateInternal(byte[] s)Resets the RNG to the givenstate.-
Methods inherited from class org.apache.commons.rng.core.BaseProvider
checkIndex, checkStateSize, composeStateInternal, extendSeed, extendSeed, fillState, fillState, restoreState, saveState, splitStateInternal, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.commons.rng.core.source32.RandomIntSource
next
-
-
-
-
Constructor Detail
-
IntProvider
public IntProvider()
Creates a new instance.
-
IntProvider
protected IntProvider(IntProvider source)
Creates a new instance copying the state from the source.This provides base functionality to allow a generator to create a copy, for example for use in the
JumpableUniformRandomProviderinterface.- Parameters:
source- Source to copy.- Since:
- 1.3
-
-
Method Detail
-
resetCachedState
protected void resetCachedState()
Reset the cached state used in the default implementation ofnextBoolean().This should be used when the state is no longer valid, for example after a jump performed for the
JumpableUniformRandomProviderinterface.- Since:
- 1.3
-
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)
-
nextInt
public int nextInt()
- Specified by:
nextIntin interfaceUniformRandomProvider
-
nextBoolean
public boolean nextBoolean()
- Specified by:
nextBooleanin interfaceUniformRandomProvider
-
nextDouble
public double nextDouble()
- Specified by:
nextDoublein interfaceUniformRandomProvider
-
nextLong
public long nextLong()
- Specified by:
nextLongin interfaceUniformRandomProvider
-
nextBytes
public void nextBytes(byte[] bytes)
- Specified by:
nextBytesin interfaceUniformRandomProvider
-
nextBytes
public void nextBytes(byte[] bytes, int start, int len)
- Specified by:
nextBytesin interfaceUniformRandomProvider
-
-