public final class RandomCompat
extends java.lang.Object
Random
class,
based on IntStream
only for now.Constructor and Description |
---|
RandomCompat()
Constructs object, inner
random created with default constructor. |
RandomCompat(long seed)
Constructs object, inner
random created with seed passed as param. |
RandomCompat(java.util.Random random)
Constructs object with the given
Random instance. |
Modifier and Type | Method and Description |
---|---|
java.util.Random |
getRandom()
Returns underlying
Random instance. |
IntStream |
ints()
Returns an effectively unlimited stream of pseudorandom
int
values. |
IntStream |
ints(int randomNumberOrigin,
int randomNumberBound)
Returns an effectively unlimited stream of pseudorandom
int
values, each conforming to the given origin (inclusive) and bound (exclusive) |
IntStream |
ints(long streamSize)
Returns a stream producing the given
streamSize number of
pseudorandom int values. |
IntStream |
ints(long streamSize,
int randomNumberOrigin,
int randomNumberBound)
Returns a stream producing the given
streamSize number
of pseudorandom int values, each conforming to the given
origin (inclusive) and bound (exclusive). |
public RandomCompat()
random
created with default constructor.public RandomCompat(long seed)
random
created with seed passed as param.seed
- seed to initialize random
objectpublic RandomCompat(java.util.Random random)
Random
instance.random
- Random
instancepublic java.util.Random getRandom()
Random
instance.Random
object instancepublic IntStream ints(long streamSize)
streamSize
number of
pseudorandom int
values.
A pseudorandom int
value is generated as if it's the result of
calling the method Random.nextInt()
streamSize
- the number of values to generateint
valuesjava.lang.IllegalArgumentException
- if streamSize
is
less than zeropublic IntStream ints()
int
values.
A pseudorandom int
value is generated as if it's the result of
calling the method Random.nextInt()
.
int
valuespublic IntStream ints(long streamSize, int randomNumberOrigin, int randomNumberBound)
streamSize
number
of pseudorandom int
values, each conforming to the given
origin (inclusive) and bound (exclusive).streamSize
- the number of values to generaterandomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) if each random valueint
values,
each with the given origin (inclusive) and bound (exclusive)java.lang.IllegalArgumentException
- if streamSize
is
less than zero, or randomNumberOrigin
is
greater than or equal to randomNumberBound
public IntStream ints(int randomNumberOrigin, int randomNumberBound)
int
values, each conforming to the given origin (inclusive) and bound (exclusive)randomNumberOrigin
- the origin (inclusive) of each random valuerandomNumberBound
- the bound (exclusive) of each random valueint
values,
each with the given origin (inclusive) and bound (exclusive)java.lang.IllegalArgumentException
- if randomNumberOrigin
is greater than or equal to randomNumberBound