public final class Randomizer
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
<T> T |
choose(java.util.Collection<T> collection)
Chooses a random item of the given collection.
|
<T> T |
choose(T[] array)
Chooses a random item of the given array.
|
void |
fill(BitVector data)
Fills the raw data storage with random data.
|
void |
fill(byte[] data)
Fills the byte array with random data.
|
void |
fill(char[] data)
Fills the char array with random data.
|
void |
fill(int[] data)
Fills the int array with random data.
|
void |
fill(long[] data)
Fills the long array with random data.
|
static Randomizer |
get()
Returns the randomizer instance.
|
RandomGenerator |
getGenerator()
Returns the current random number generator.
|
int |
next()
Generates the next random integer value.
|
java.math.BigInteger |
nextBigIntegerRange(java.math.BigInteger min,
java.math.BigInteger max)
Returns a random number from the given range.
|
boolean |
nextBoolean()
Generates the next random boolean.
|
byte |
nextByte()
Generates the next random byte.
|
char |
nextChar()
Generates the next random char.
|
int |
nextInt()
Generates the next random int.
|
int |
nextIntField(int width)
Returns a random number of the given bit size (width).
|
int |
nextIntField(int lo,
int hi)
Returns a number with the randomized range of bits (field).
|
int |
nextIntRange(int min,
int max)
Returns a random number from the given range.
|
long |
nextLong()
Generates the next random long.
|
long |
nextLongField(int width)
Returns a random number of the given bit size (width).
|
long |
nextLongField(int lo,
int hi)
Returns a number with the randomized range of bits (field).
|
long |
nextLongRange(long min,
long max)
Returns a random number from the given range.
|
void |
setGenerator(RandomGenerator generator)
Sets the current random number generator.
|
void |
setSeed(int seed)
Sets the new seed of the random number generator.
|
public static Randomizer get()
public RandomGenerator getGenerator()
public void setGenerator(RandomGenerator generator)
generator
- the random number generator to be set.public void setSeed(int seed)
seed
- the seed to be set.public int next()
public boolean nextBoolean()
public byte nextByte()
public char nextChar()
public int nextInt()
public long nextLong()
public int nextIntRange(int min, int max)
min
- the low bound of the range.max
- the high bound of the range.public int nextIntField(int width)
width
- the bit size.public int nextIntField(int lo, int hi)
lo
- the low bound of the field.hi
- the high bound of the field.public long nextLongRange(long min, long max)
min
- the low bound of the range.max
- the high bound of the range.public long nextLongField(int width)
width
- the bit size.public long nextLongField(int lo, int hi)
lo
- the low bound of the field.hi
- the high bound of the field.public java.math.BigInteger nextBigIntegerRange(java.math.BigInteger min, java.math.BigInteger max)
min
- the low bound of the range.max
- the high bound of the range.public <T> T choose(T[] array)
array
- the array whose items are chosen.java.lang.NullPointerException
- if array == null
.java.lang.IllegalArgumentException
- if array
is empty.public <T> T choose(java.util.Collection<T> collection)
collection
- the collection whose items are chosen.java.lang.NullPointerException
- if collection == null
.java.lang.IllegalArgumentException
- if collection
is empty.public void fill(byte[] data)
data
- the array to be randomized.public void fill(char[] data)
data
- the array to be randomized.public void fill(int[] data)
data
- the array to be randomized.public void fill(long[] data)
data
- the array to be randomized.public void fill(BitVector data)
data
- the raw data storage to be randomized.