Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## waba.util
Class Random

    java.lang.Object
      |
      +--waba.util.Random

public class Random
extends Object

This is a simple Linear Congruential Generator which produces random numbers in the range [0,2^31), derived from ran0 in Numerical Recipies. Note that ran0 isn't wonderfully random -- there are much better generators out there -- but it'll do the job, and it's fast and has low memory consumption.

Field Summary
`static int` | `IA`
`static int` | `IM`
`static int` | `IQ`
`static int` | `IR`
`static int` | `ZERO_SEED_REPLACEMENT`

Constructor Summary
`Random()` Randomizes based on the current timestamp
`Random(int _seed)` The only reasonable seeds are between 0 and 2^31 inclusive; if you're negative, it'll get the absolute value of it.

Method Summary
`int` | `getRandom(int n)`
`protected int` | `next(int bits)` bits should be <= 31
`float` | `nextFloat()` Returns a floating-point value in the half-open range [0,1).
`int` | `nextInt(int n)` Returns an integer in the range [0,n). n must be > 0, else -1 is returned.
`char` | `rand(char s, char e)` Returns either random character in the given region.
`int` | `rand(int s, int e)` Returns either random integer in the given region.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, toString, wait, wait`

Field Detail

### IA

    public static final int IA

### IM

    public static final int IM

### IQ

    public static final int IQ

### IR

    public static final int IR

### ZERO_SEED_REPLACEMENT

    public static final int ZERO_SEED_REPLACEMENT

Constructor Detail

### Random

    public Random(int _seed)

  The only reasonable seeds are between 0 and 2^31 inclusive; if you're negative, it'll get the absolute value of it.

### Random

    public Random()

  Randomizes based on the current timestamp

Method Detail

### next

    protected int next(int bits)

  bits should be <= 31

### nextFloat

    public float nextFloat()

  Returns a floating-point value in the half-open range [0,1).

### nextInt

    public int nextInt(int n)

  Returns an integer in the range [0,n). n must be > 0, else -1 is returned.

### getRandom

    public int getRandom(int n)

### rand

    public char rand(char s,
                     char e)

  Returns either random character in the given region. Eg: rand('a', 'e') returns a random character in the range of 'a' to 'e'. Added by Imran Zahid
  Parameters:
    `s` - the start character in the range
    `e` - the ending character in the range

### rand

    public int rand(int s,
                    int e)

  Returns either random integer in the given region. Eg: rand(1, 10) returns a random integer in the range of 1 to 10. Added by Imran Zahid
  Parameters:
    `s` - the start number in the range
    `e` - the ending number in the range

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD