org.amino.utility
Class FastRandom

java.lang.Object
  extended by org.amino.utility.FastRandom

public final class FastRandom
extends java.lang.Object

This class provides fast random method. The quality of random number is not as good as standard library. And it's also not thread-safe, which means two threads might get the same random number if data race occurs.

Author:
Zhi Gan (ganzhi@gmail.com)

Method Summary
static int nextInt(int upper)
          Generate a pseudo-random integer.
static int rand()
          Generate a pseudo-random integer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

rand

public static int rand()
Generate a pseudo-random integer. The range of generated number is [0, 24001)

Returns:
a pseudo-random integer which lies between [0, 24001)

nextInt

public static int nextInt(int upper)
Generate a pseudo-random integer. The range of generated number is [0, upper]

Parameters:
upper - Upper bound of generated random number
Returns:
a pseudo-random integer which lies between [0, min(24001, upper))


Copyright © 2008. All Rights Reserved.