public class XoshiroStarStar64RNG extends java.lang.Object implements RandomnessSource, java.io.Serializable
FourWheelRNG
are:
Modifier and Type | Field and Description |
---|---|
protected long |
stateA
The first state; can be any long, as long as all states are not 0.
|
protected long |
stateB
The second state; can be any long, as long as all states are not 0.
|
protected long |
stateC
The third state; can be any long, as long as all states are not 0.
|
protected long |
stateD
The fourth state; can be any long, as long as all states are not 0.
|
Constructor and Description |
---|
XoshiroStarStar64RNG()
Creates a new FourWheelRandom with a random state.
|
XoshiroStarStar64RNG(long seed)
Creates a new FourWheelRandom with the given seed; all
long values are permitted. |
XoshiroStarStar64RNG(long stateA,
long stateB,
long stateC,
long stateD)
Creates a new FourWheelRandom with the given four states; all
long values are permitted. |
Modifier and Type | Method and Description |
---|---|
XoshiroStarStar64RNG |
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.
|
boolean |
equals(java.lang.Object o) |
long |
getStateA() |
long |
getStateB() |
long |
getStateC() |
long |
getStateD() |
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.
|
void |
setSeed(long seed)
This initializes all 4 states of the generator to random values based on the given seed.
|
void |
setState(long stateA,
long stateB,
long stateC,
long stateD)
Sets the state completely to the given four state variables.
|
void |
setStateA(long stateA)
Sets the first part of the state.
|
void |
setStateB(long stateB)
Sets the second part of the state.
|
void |
setStateC(long stateC)
Sets the third part of the state.
|
void |
setStateD(long stateD)
Sets the fourth part of the state.
|
java.lang.String |
toString() |
protected long stateA
protected long stateB
protected long stateC
protected long stateD
public XoshiroStarStar64RNG()
public XoshiroStarStar64RNG(long seed)
long
values are permitted.
The seed will be passed to setSeed(long)
to attempt to adequately distribute the seed randomly.seed
- any long
valuepublic XoshiroStarStar64RNG(long stateA, long stateB, long stateC, long stateD)
long
values are permitted.
These states will be used verbatim, as long as they are not all 0. In that case, stateD is changed.stateA
- any long
valuestateB
- any long
valuestateC
- any long
valuestateD
- any long
valuepublic void setSeed(long seed)
nextLong()
(because stateB
is guaranteed to be
different for every different seed
).seed
- the initial seed; may be any longpublic long getStateA()
public void setStateA(long stateA)
stateA
- can be any longpublic long getStateB()
public void setStateB(long stateB)
stateB
- can be any longpublic long getStateC()
public void setStateC(long stateC)
stateC
- can be any longpublic long getStateD()
public void setStateD(long stateD)
stateD
- can be any longpublic void setState(long stateA, long stateB, long stateC, long stateD)
setStateA(long)
, setStateB(long)
,
setStateC(long)
, and setStateD(long)
as a group.stateA
- the first state; can be any longstateB
- the second state; can be any longstateC
- the third state; can be any longstateD
- the fourth state; this will be returned as-is if the next call is to nextLong()
public long nextLong()
RandomnessSource
nextLong
in interface RandomnessSource
public int next(int bits)
RandomnessSource
next
in interface RandomnessSource
bits
- the number of bits to be returnedpublic XoshiroStarStar64RNG copy()
RandomnessSource
copy
in interface RandomnessSource
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © Eben Howard 2012–2022. All rights reserved.