peersim.util
Class ExtendedRandom

java.lang.Object
  extended by java.util.Random
      extended by peersim.util.ExtendedRandom
All Implemented Interfaces:
java.io.Serializable

public class ExtendedRandom
extends java.util.Random

Extends the functionality of java.util.Random.

See Also:
Serialized Form

Constructor Summary
ExtendedRandom(long seed)
          Calls super constructor.
 
Method Summary
 long getLastSeed()
          Returns the last random seed that was set explicitly.
 long nextLong(long n)
          Implements nextLong(long) the same way nexInt(int) is implemented in java.util.Random.
 int nextPoisson(double mean)
          Extracts the next integer, according to a Poisson distribution.
 void setSeed(long seed)
          Sets random seed.
 
Methods inherited from class java.util.Random
next, 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
 

Constructor Detail

ExtendedRandom

public ExtendedRandom(long seed)
Calls super constructor. Also stores the seed to be returned by getLastSeed().

Method Detail

nextPoisson

public int nextPoisson(double mean)
Extracts the next integer, according to a Poisson distribution.

Parameters:
mean - The mean of the Poisson distribution.
Returns:
An integer Poisson extraction.

nextLong

public long nextLong(long n)
Implements nextLong(long) the same way nexInt(int) is implemented in java.util.Random.

Parameters:
n - the bound on the random number to be returned. Must be positive.
Returns:
a pseudorandom, uniformly distributed long value between 0 (inclusive) and n (exclusive).

setSeed

public void setSeed(long seed)
Sets random seed. Calls super method but also stores the seed to be returned by getLastSeed().

Overrides:
setSeed in class java.util.Random

getLastSeed

public long getLastSeed()
Returns the last random seed that was set explicitly. Either at construction time or through setSeed(long).