Package squidpony.squidmath
Interface StatefulRandomness
- All Superinterfaces:
RandomnessSource
,Serializable
- All Known Subinterfaces:
IStatefulRNG
- All Known Implementing Classes:
DeckRNG
,DistributedRNG
,DiverRNG
,EditRNG
,FlawedRandomness.AddRotate
,FlawedRandomness.BigCounter
,GWTRNG
,Lathe32RNG
,LFSR
,LightRNG
,LinnormRNG
,MizuchiRNG
,MoonwalkRNG
,NLFSR
,PermutedRNG
,PintRNG
,PulleyRNG
,SilkRNG
,Starfish32RNG
,StatefulRNG
,ThrustAltRNG
,VanDerCorputQRNG
public interface StatefulRandomness extends RandomnessSource
A simple interface for RandomnessSources that have the additional property of a state that can be re-set.
Created by Tommy Ettinger on 9/15/2015.
-
Method Summary
Modifier and Type Method Description RandomnessSource
copy()
Produces a copy of this StatefulRandomness 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.long
getState()
Get the current internal state of the StatefulRandomness as a long.void
setState(long state)
Set the current internal state of this StatefulRandomness with a long.
-
Method Details
-
getState
long getState()Get the current internal state of the StatefulRandomness as a long.- Returns:
- the current internal state of this object.
-
setState
Set the current internal state of this StatefulRandomness with a long.- Parameters:
state
- a 64-bit long. You should avoid passing 0, even though some implementations can handle that.
-
copy
Produces a copy of this StatefulRandomness 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.- Specified by:
copy
in interfaceRandomnessSource
- Returns:
- a copy of this StatefulRandomness
-