public class XORShiftRNG extends Random
Very fast pseudo random number generator. See this page for a description. This RNG has a period of about 2^160, which is not as long as the MersenneTwisterRNG but it is faster.
NOTE: Because instances of this class require 160-bit seeds, it is not possible to seed this RNG using the
Random.setSeed(long)
method inherited from Random
. Calls to this method will have no effect. Instead the
seed must be set by a constructor.
Constructor and Description |
---|
XORShiftRNG()
Creates an RNG and seeds it with the specified seed data.
|
Modifier and Type | Method and Description |
---|---|
static int |
convertBytesToInt(byte[] bytes,
int offset)
Take four bytes from the specified position in the specified block and convert them into a 32-bit int, using the
big-endian convention.
|
static int[] |
convertBytesToInts(byte[] bytes)
Convert an array of bytes into an array of ints.
|
byte[] |
getSeed() |
protected int |
next(int bits) |
public XORShiftRNG()
public byte[] getSeed()
public static int convertBytesToInt(byte[] bytes, int offset)
bytes
- The data to read from.offset
- The position to start reading the 4-byte int from.public static int[] convertBytesToInts(byte[] bytes)
bytes
- The data to read from.Copyright © 2019. All rights reserved.