public class XoRoRNG extends Object implements RandomnessSource
Constructor and Description |
---|
XoRoRNG()
Creates a new generator seeded using Math.random.
|
XoRoRNG(long seed) |
Modifier and Type | Method and 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.
|
boolean |
nextBoolean() |
void |
nextBytes(byte[] bytes) |
double |
nextDouble() |
float |
nextFloat() |
int |
nextInt()
Can return any int, positive or negative, of any size permissible in a 32-bit signed integer.
|
int |
nextInt(int bound)
Exclusive on the upper bound.
|
int |
nextInt(int lower,
int upper)
Inclusive lower, exclusive upper.
|
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.
|
long |
nextLong(long bound)
Exclusive on the upper bound.
|
void |
setSeed(long seed)
Sets the seed of this generator.
|
String |
toString() |
public XoRoRNG()
public XoRoRNG(long seed)
public int next(int bits)
RandomnessSource
next
in interface RandomnessSource
bits
- the number of bits to be returnedpublic long nextLong()
RandomnessSource
nextLong
in interface RandomnessSource
public RandomnessSource copy()
copy
in interface RandomnessSource
public int nextInt()
public int nextInt(int bound)
bound
- the upper bound; should be positivepublic int nextInt(int lower, int upper)
lower
- the lower bound, inclusive, can be positive or negativeupper
- the upper bound, exclusive, should be positive, must be greater than lowerpublic long nextLong(long bound)
bound
- the upper bound; should be positivepublic double nextDouble()
public float nextFloat()
public boolean nextBoolean()
public void nextBytes(byte[] bytes)
public void setSeed(long seed)
seed
- the number to use as the seedCopyright © 2012–2016. All rights reserved.