public class RandomDefault extends RandomMersenneTwister
| Constructor and Description |
|---|
RandomDefault()
Constructs a new
RandomDefault. |
| Modifier and Type | Method and Description |
|---|---|
static int[] |
pack(byte[] buf)
This simply utility method can be used in cases where a byte array of
seed data is to be used to repeatedly re-seed the random number sequence.
|
void |
setSeed(byte[] buf)
This method resets the state of this instance using the byte array of
seed data provided.
|
void |
setSeed(int[] buf)
This method resets the state of this instance using the integer array of
seed data provided.
|
void |
setSeed(long seed)
This method resets the state of this instance using the 64 bits of seed
data provided.
|
public RandomDefault()
RandomDefault.public void setSeed(long seed)
If this instance was initialised in 'compatibility' mode then this method will only use the lower 32 bits of any seed value passed in and will match the behaviour of the original C code exactly with respect to state initialisation.
public void setSeed(byte[] buf)
buf - The non-empty byte array of seed information.NullPointerException - if the buffer is null.IllegalArgumentException - if the buffer has zero length.public void setSeed(int[] buf)
buf - The non-empty integer array of seed information.NullPointerException - if the buffer is null.IllegalArgumentException - if the buffer has zero length.public static int[] pack(byte[] buf)
If the length of the byte array is not a multiple of 4 then it is implicitly padded with zeros as necessary. For example:
byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 }
becomes
int[] { 0x04030201, 0x00000605 }
Note that this method will not complain if the given byte array is empty and will produce an empty integer array, but the setSeed() method will throw an exception if the empty integer array is passed to it.
buf - The non-null byte array to be packed.NullPointerException - if the given byte array is null.