Package squidpony.squidmath
Interface RandomnessSource
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
FlawedRandomness
,IRNG
,IStatefulRNG
,SkippingRandomness
,StatefulRandomness
- All Known Implementing Classes:
AbstractRNG
,BasicRandom32
,BasicRandom64
,ChaosRNG
,CriticalRNG
,DeckRNG
,DharmaRNG
,DistributedRNG
,DiverRNG
,EditRNG
,FlawedRandomness.AddRotate
,FlawedRandomness.BigCounter
,GearRNG
,GoatRNG
,GWTRNG
,IsaacRNG
,Lathe32RNG
,LFSR
,LightRNG
,LinnormRNG
,LongPeriodRNG
,MersenneTwister
,MiniMover64RNG
,MizuchiRNG
,MoonwalkRNG
,Mover32RNG
,Mover64RNG
,NLFSR
,OrbitRNG
,Oriole32RNG
,PermutedRNG
,PintRNG
,PulleyRNG
,RNG
,SilkRNG
,SobolQRNG
,Starfish32RNG
,StatefulRNG
,TangleRNG
,ThrustAltRNG
,TweakRNG
,VanDerCorputQRNG
,XoRoRNG
,XoshiroStarPhi32RNG
public interface RandomnessSource extends Serializable
This interface defines the interactions required of a random number
generator. It is a replacement for Java's built-in Random because for
improved performance.
- Author:
- Eben Howard - http://squidpony.com - howard@squidpony.com
-
Method Summary
Modifier and Type Method Description RandomnessSource
copy()
Produces a copy of this RandomnessSource that, if next() and/or nextLong() are called on this object and the copy, both will generate the same sequence of random numbers from the point copy() was called.int
next(int bits)
Using this method, any algorithm that might use the built-in Java Random can interface with this randomness source.long
nextLong()
Using this method, any algorithm that needs to efficiently generate more than 32 bits of random data can interface with this randomness source.
-
Method Details
-
next
Using this method, any algorithm that might use the built-in Java Random can interface with this randomness source.- Parameters:
bits
- the number of bits to be returned- Returns:
- the integer containing the appropriate number of bits
-
nextLong
long nextLong()Using this method, any algorithm that needs to efficiently generate more than 32 bits of random data can interface with this randomness source. Get a random long between Long.MIN_VALUE and Long.MAX_VALUE (both inclusive).- Returns:
- a random long between Long.MIN_VALUE and Long.MAX_VALUE (both inclusive)
-
copy
Produces a copy of this RandomnessSource that, if next() and/or nextLong() are called on this object and the copy, both will generate the same sequence of random numbers from the point copy() was called. This just needs to copy the state so it isn't shared, usually, and produce a new value with the same exact state.- Returns:
- a copy of this RandomnessSource
-