All Packages  Class Hierarchy  This Package  Previous  Next  Index  

Class DataStructures.Random

java.lang.Object
    |
    +----DataStructures.Random

public class Random
extends Object
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 Index

 o Random()
Construct this Random object with initial state obtained from system clock.
 o Random(int)
Construct this Random object with specified initial state.

Method Index

 o main(String[])
 o permute(Object[])
Randomly rearrange an array.
 o random0_1()
Return a pseudorandom double in the open range 0..1 and change the internal state.
 o randomInt()
Return a pseudorandom int, and change the internal state.
 o randomInt(int, int)
Return an int in the closed range [low,high], and change the internal state.
 o randomIntWRONG()
Return a pseudorandom int, and change the internal state.
 o randomLong(long, long)
Return an long in the closed range [low,high], and change the internal state.

Constructors

 o Random
public Random()
Construct this Random object with initial state obtained from system clock.

 o Random
public Random(int initialValue)
Construct this Random object with specified initial state.

Parameters:
initialValue - the initial state.

Methods

 o randomInt
public int randomInt()
Return a pseudorandom int, and change the internal state.

Returns:
the pseudorandom int.
 o randomIntWRONG
public int randomIntWRONG()
Return a pseudorandom int, and change the internal state. DOES NOT WORK.

Returns:
the pseudorandom int.
 o random0_1
public double random0_1()
Return a pseudorandom double in the open range 0..1 and change the internal state.

Returns:
the pseudorandom double.
 o randomInt
public int randomInt(int low,
                     int high)
Return an int in the closed range [low,high], and change the internal state.

Parameters:
low - the minimum value returned.
high - the maximum value returned.
Returns:
the pseudorandom int.
 o randomLong
public long randomLong(long low,
                       long high)
Return an long in the closed range [low,high], and change the internal state.

Parameters:
low - the minimum value returned.
high - the maximum value returned.
Returns:
the pseudorandom long.
 o permute
public static final void permute(Object[] a)
Randomly rearrange an array. The random numbers used depend on the time and day.

Parameters:
a - the array.
 o main
public static void main(String[] args)

All Packages  Class Hierarchy  This Package  Previous  Next  Index