org.mmbase.util
Class RandomPool

java.lang.Object
  |
  +--org.mmbase.util.RandomPool

public class RandomPool
extends java.lang.Object

Class for holding a pool of random numbers. Calling stir(long) takes care of generating a new 'random' number. Calling value() returns the current random number.

Version:
9 Jan 1997
Author:
Rico Jansen, Pierre van Rooden (javadocs)

Constructor Summary
RandomPool()
          Create a pool.
RandomPool(long init)
          Create a pool.
 
Method Summary
 void stir(long x)
          Maintain a pool of randomness using a modified 64-bit congruential generator with multipliers dynamically selected from a set of pseudo-random values.
 long value_and_stir()
          Stirs, then returns the (new) current random value.
 long value_and_stir(long mix)
          Stirs, then returns the (new) current random value.
 long value()
          Returns the current random value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RandomPool

public RandomPool()
Create a pool. Use the current time (long milliseconds) as a source of randomness

RandomPool

public RandomPool(long init)
Create a pool.
Parameters:
init - the source of randomness
Method Detail

stir

public void stir(long x)
Maintain a pool of randomness using a modified 64-bit congruential generator with multipliers dynamically selected from a set of pseudo-random values.
Parameters:
x - the source of randomness

value

public long value()
Returns the current random value.

value_and_stir

public long value_and_stir()
Stirs, then returns the (new) current random value. Use the current time (long milliseconds) as a source of randomness for stirring.

value_and_stir

public long value_and_stir(long mix)
Stirs, then returns the (new) current random value.
Parameters:
init - the source of randomness for stirring


MMBase 2001