org.apache.myfaces.util
Class XorShiftRandom

java.lang.Object
  extended by org.apache.myfaces.util.XorShiftRandom
Direct Known Subclasses:
ThreadsafeXorShiftRandom

public class XorShiftRandom
extends Object

A simple XORShift Random generator. This class is NOT synchronized, you need to do that yourself if needed!


Constructor Summary
XorShiftRandom(long initialSeed)
           
 
Method Summary
 long random()
          Calculate a random value based on the previous value stored in this instance.
static long random(long randomStart)
          Calculate a random value based on the given start Value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XorShiftRandom

public XorShiftRandom(long initialSeed)
Method Detail

random

public long random()
Calculate a random value based on the previous value stored in this instance. If you use this method in a concurring way, you need to synchronize the access!

Returns:

random

public static long random(long randomStart)
Calculate a random value based on the given start Value.

Parameters:
randomStart - the start value. Usually the result of the previous invocation
Returns:
the new random value.


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.