com.newisys.random
Class LinearCongruentialFactory

java.lang.Object
  extended by com.newisys.random.LinearCongruentialFactory
All Implemented Interfaces:
PRNGFactory

public final class LinearCongruentialFactory
extends Object
implements PRNGFactory

A factory implementation for the linear congruential pseudorandom number generator.


Field Summary
static LinearCongruentialFactory INSTANCE
          A singleton instance of LinearCongruentialFactory.
 
Constructor Summary
LinearCongruentialFactory()
           
 
Method Summary
 PRNG newInstance()
          Creates a new pseudorandom number generator with an arbitrarily chosen seed.
 PRNG newInstance(long seed)
          Creates a new pseudorandom number generator with the given seed.
 PRNG newInstance(PRNG seedSource)
          Creates a new pseudorandom number generator with a seed generated using the given generator.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final LinearCongruentialFactory INSTANCE
A singleton instance of LinearCongruentialFactory.

Constructor Detail

LinearCongruentialFactory

public LinearCongruentialFactory()
Method Detail

newInstance

public PRNG newInstance()
Description copied from interface: PRNGFactory
Creates a new pseudorandom number generator with an arbitrarily chosen seed. Generally, this seed will be a non-constant value, such as the current system time, so this method is not suitable for cases where reproducibility is desired.

Specified by:
newInstance in interface PRNGFactory
Returns:
a new PRNG instance

newInstance

public PRNG newInstance(long seed)
Description copied from interface: PRNGFactory
Creates a new pseudorandom number generator with the given seed. For a given factory, if two generators are created with the same seed, they will produce the same sequence of values.

Specified by:
newInstance in interface PRNGFactory
Parameters:
seed - the value used to seed the new generator
Returns:
a new PRNG instance

newInstance

public PRNG newInstance(PRNG seedSource)
Description copied from interface: PRNGFactory
Creates a new pseudorandom number generator with a seed generated using the given generator. This method is useful for creating families of independent random number generators all seeded from the same source.

Specified by:
newInstance in interface PRNGFactory
Parameters:
seedSource - the source of random data used to seed the new generator
Returns:
a new PRNG instance