vitro.util
Class MTRandom
java.lang.Object
java.util.Random
vitro.util.MTRandom
- All Implemented Interfaces:
- Serializable
public class MTRandom
- extends Random
An implementation of the Mersenne Twister algorithm.
- See Also:
- Serialized Form
Constructor Summary |
MTRandom()
Create a new Mersenne Twister generator based on the JVM's nanotime. |
MTRandom(long seed)
Create a new Mersenne Twister generator based on a specified seed. |
Method Summary |
protected int |
next(int bits)
Get an integer value with the specified number of bits. |
void |
setSeed(long seed)
Set this generator's seed. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
MTRandom
public MTRandom()
- Create a new Mersenne Twister generator based on the JVM's nanotime.
- See Also:
System.nanoTime()
MTRandom
public MTRandom(long seed)
- Create a new Mersenne Twister generator based on a specified seed. Note
that only the last 32 bits of the seed are used.
- Parameters:
seed
- the generating seed.
setSeed
public void setSeed(long seed)
- Set this generator's seed. Note that this reconstructs the object in its
entirety. Note that only the last 32 bits of the seed are used.
- Overrides:
setSeed
in class Random
- Parameters:
seed
- the generating seed.
next
protected int next(int bits)
- Get an integer value with the specified number of bits. Implements the
core Mersenne Twister algorithm. Additionally implements the bit culling
algorithm
(int)(seed >>> (48 - bits))
as described in the super class.
- Overrides:
next
in class Random
- Parameters:
bits
- the number of bits in the generated random value.
- Returns:
- the generated random value.
- See Also:
Random.next(int)