vitro.util
Class MTRandom

java.lang.Object
  extended by java.util.Random
      extended by vitro.util.MTRandom
All Implemented Interfaces:
Serializable

public class MTRandom
extends Random

An implementation of the Mersenne Twister algorithm.

See Also:
Serialized Form

Field Summary
static long serialVersionUID
           
 
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.util.Random
nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

public static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

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.
Method Detail

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)