Random's, and its cycle length is 2128 − 1, which
is more than enough for any single-thread application. More details and algorithms can be found
here.
Instances of RandomXS128 are not thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private static final double | NORM_DOUBLE
Normalization constant for double. |
| private static final double | NORM_FLOAT
Normalization constant for float. |
| private long | seed0
The first half of the internal state of this pseudo-random number generator. |
| private long | seed1
The second half of the internal state of this pseudo-random number generator. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | RandomXS128(long
the initial seed seed)Creates a new random number generator using a single |
| public | RandomXS128(long
the first part of the initial seed seed0, long the second part of the initial seed seed1)Creates a new random number generator using two |
| Modifier and Type | Method and Description |
|---|---|
| public long | Returns: the internal seed that can be used in setStatemust be 0 or 1, designating which of the 2 long seeds to return seed)Returns the internal seeds to allow state saving. |
| private static final long | |
| protected final int | next(int bits)
Overrides java. This protected method is final because, contrary to the superclass, it's not used anymore by the other methods. |
| public boolean | nextBoolean()
Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed |
| public void | nextBytes(final byte[] bytes)
Overrides java. Overrides default java. Generates random bytes and places them into a user-supplied byte array. |
| public double | nextDouble()
Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed |
| public float | nextFloat()
Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed |
| public int | nextInt()
Overrides java. Overrides default java. Returns the next pseudo-random, uniformly distributed |
| public int | Returns: the next pseudo-randomint value between 0 (inclusive) and n (exclusive).the positive bound on the random number to be returned. n)Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed |
| public long | nextLong()
Overrides java. Implements java. Returns the next pseudo-random, uniformly distributed |
| public long | Returns: the next pseudo-randomlong value between 0 (inclusive) and n (exclusive).the positive bound on the random number to be returned. n)Overrides default java. Returns a pseudo-random, uniformly distributed |
| public void | setSeed(final long
a nonzero seed for this generator (if zero, the generator will be seeded with seed)Long#MIN_VALUE).Overrides java. Sets the internal seed of this generator based on the given |
| public void | setState(final long
the first part of the internal state seed0, final long the second part of the internal state seed1)Sets the internal state of this generator. |
| NORM_DOUBLE | back to summary |
|---|---|
| private static final double NORM_DOUBLE Normalization constant for double. | |
| NORM_FLOAT | back to summary |
|---|---|
| private static final double NORM_FLOAT Normalization constant for float. | |
| seed0 | back to summary |
|---|---|
| private long seed0 The first half of the internal state of this pseudo-random number generator. | |
| seed1 | back to summary |
|---|---|
| private long seed1 The second half of the internal state of this pseudo-random number generator. | |
| RandomXS128 | back to summary |
|---|---|
| public RandomXS128() Creates a new random number generator. This constructor sets the seed of the random number generator to a value very likely to be distinct from any other invocation of this constructor.
This implementation creates a | |
| RandomXS128 | back to summary |
|---|---|
| public RandomXS128(long seed) Creates a new random number generator using a single
| |
| RandomXS128 | back to summary |
|---|---|
| public RandomXS128(long seed0, long seed1) Creates a new random number generator using two
| |
| getState | back to summary |
|---|---|
| public long getState(int seed) Returns the internal seeds to allow state saving.
| |
| murmurHash3 | back to summary |
|---|---|
| private static final long murmurHash3(long x) | |
| next | back to summary |
|---|---|
| protected final int next(int bits) Overrides java. This protected method is final because, contrary to the superclass, it's not used anymore by the other methods.
| |
| nextBoolean | back to summary |
|---|---|
| public boolean nextBoolean() Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed
This implementation uses
| |
| nextBytes | back to summary |
|---|---|
| public void nextBytes(final byte[] bytes) Overrides java. Overrides default java. Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the length of the byte array.
This implementation uses
| |
| nextDouble | back to summary |
|---|---|
| public double nextDouble() Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed
This implementation uses
| |
| nextFloat | back to summary |
|---|---|
| public float nextFloat() Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed
This implementation uses
| |
| nextInt | back to summary |
|---|---|
| public int nextInt() Overrides java. Overrides default java. Returns the next pseudo-random, uniformly distributed
This implementation uses
| |
| nextInt | back to summary |
|---|---|
| public int nextInt(final int n) Overrides java. Overrides default java. Returns a pseudo-random, uniformly distributed
This implementation uses
| |
| nextLong | back to summary |
|---|---|
| public long nextLong() Overrides java. Implements java. Returns the next pseudo-random, uniformly distributed Subclasses should override this, as this is used by all other methods.
| |
| nextLong | back to summary |
|---|---|
| public long nextLong(final long n) Overrides default java. Returns a pseudo-random, uniformly distributed
This implementation uses
| |
| setSeed | back to summary |
|---|---|
| public void setSeed(final long seed) Overrides java. Sets the internal seed of this generator based on the given The given seed is passed twice through a hash function. This way, if the user passes a small value we avoid the short irregular transient associated with states having a very small number of bits set.
| |
| setState | back to summary |
|---|---|
| public void setState(final long seed0, final long seed1) Sets the internal state of this generator.
| |