|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--DataStructures.Random
Random number class, using a 31-bit linear congruential generator. Note that java.util contains a class Random, so watch out for name conflicts.
Constructor Summary | |
Random()
Construct this Random object with initial state obtained from system clock. |
|
Random(int initialValue)
Construct this Random object with specified initial state. |
Method Summary | |
static void |
main(java.lang.String[] args)
|
static void |
permute(java.lang.Object[] a)
Randomly rearrange an array. |
double |
random0_1()
Return a pseudorandom double in the open range 0..1 and change the internal state. |
int |
randomInt()
Return a pseudorandom int, and change the internal state. |
int |
randomInt(int low,
int high)
Return an int in the closed range [low,high], and change the internal state. |
int |
randomIntWRONG()
Return a pseudorandom int, and change the internal state. |
long |
randomLong(long low,
long high)
Return an long in the closed range [low,high], and change the internal state. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Random()
public Random(int initialValue)
initialValue
- the initial state.Method Detail |
public int randomInt()
public int randomIntWRONG()
public double random0_1()
public int randomInt(int low, int high)
low
- the minimum value returned.high
- the maximum value returned.public long randomLong(long low, long high)
low
- the minimum value returned.high
- the maximum value returned.public static final void permute(java.lang.Object[] a)
a
- the array.public static void main(java.lang.String[] args)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |