Package squidpony.squidmath
Class JavaRNG
java.lang.Object
squidpony.squidmath.JavaRNG
- All Implemented Interfaces:
Serializable,RandomnessSource
public class JavaRNG extends Object implements RandomnessSource, Serializable
This makes java.util.Random available for testing purposes.
It is relevant mainly as example code, or if you want to
compare what your results would have been without using a
better RNG. Results might not be apparent in some cases,
although the terrible performance of java.util.Random is
likely to be the first thing a user notices if this is
used heavily (i.e. to generate white noise with one call
to
nextDouble() per cell).- Author:
- Ben McLean
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description JavaRNGcopy()booleanequals(Object o)inthashCode()intnext(int bits)booleannextBoolean()Gets a random value, true or false.voidnextBytes(byte[] bytes)Given a byte array as a parameter, this will fill the array with random bytes (modifying it in-place).doublenextDouble()doublenextDouble(double outer)floatnextFloat()Gets a uniform random float in the range [0.0,1.0)intnextInt()intnextInt(int bound)intnextInt(int lower, int upper)Inclusive lower, exclusive upper.longnextLong()StringtoString()
-
Field Details
-
Constructor Details
-
Method Details
-
next
- Specified by:
nextin interfaceRandomnessSource
-
nextLong
- Specified by:
nextLongin interfaceRandomnessSource
-
copy
- Specified by:
copyin interfaceRandomnessSource
-
nextInt
-
nextInt
-
nextInt
Inclusive lower, exclusive upper.- Parameters:
lower- the lower bound, inclusive, can be positive or negativeupper- the upper bound, exclusive, should be positive, must be greater than lower- Returns:
- a random int at least equal to lower and less than upper
-
nextDouble
-
nextDouble
-
nextFloat
Gets a uniform random float in the range [0.0,1.0)- Returns:
- a random float at least equal to 0.0 and less than 1.0
-
nextBoolean
Gets a random value, true or false.- Returns:
- a random true or false value.
-
nextBytes
Given a byte array as a parameter, this will fill the array with random bytes (modifying it in-place). -
toString
-
equals
-
hashCode
-