public interface UniformRandomProvider
Modifier and Type | Method and Description |
---|---|
default DoubleStream |
doubles()
Returns an effectively unlimited stream of
double values between 0
(inclusive) and 1 (exclusive). |
default DoubleStream |
doubles(double origin,
double bound)
Returns an effectively unlimited stream of
double values between the
specified origin (inclusive) and the specified bound (exclusive). |
default DoubleStream |
doubles(long streamSize)
Returns a stream producing the given
streamSize number of double
values between 0 (inclusive) and 1 (exclusive). |
default DoubleStream |
doubles(long streamSize,
double origin,
double bound)
Returns a stream producing the given
streamSize number of double
values between the specified origin (inclusive) and the specified
bound (exclusive). |
default IntStream |
ints()
Returns an effectively unlimited stream of
int values. |
default IntStream |
ints(int origin,
int bound)
Returns an effectively unlimited stream of
int values between the specified
origin (inclusive) and the specified bound (exclusive). |
default IntStream |
ints(long streamSize)
Returns a stream producing the given
streamSize number of int
values. |
default IntStream |
ints(long streamSize,
int origin,
int bound)
Returns a stream producing the given
streamSize number of int
values between the specified origin (inclusive) and the specified
bound (exclusive). |
default LongStream |
longs()
Returns an effectively unlimited stream of
long values. |
default LongStream |
longs(long streamSize)
Returns a stream producing the given
streamSize number of long
values. |
default LongStream |
longs(long origin,
long bound)
Returns an effectively unlimited stream of
long values between the
specified origin (inclusive) and the specified bound (exclusive). |
default LongStream |
longs(long streamSize,
long origin,
long bound)
Returns a stream producing the given
streamSize number of long
values between the specified origin (inclusive) and the specified
bound (exclusive). |
default boolean |
nextBoolean()
Generates a
boolean value. |
default void |
nextBytes(byte[] bytes)
Generates
byte values and places them into a user-supplied array. |
default void |
nextBytes(byte[] bytes,
int start,
int len)
Generates
byte values and places them into a user-supplied array. |
default double |
nextDouble()
Generates a
double value between 0 (inclusive) and 1 (exclusive). |
default double |
nextDouble(double bound)
Generates a
double value between 0 (inclusive) and the
specified bound (exclusive). |
default double |
nextDouble(double origin,
double bound)
Generates a
double value between the specified origin (inclusive)
and the specified bound (exclusive). |
default float |
nextFloat()
Generates a
float value between 0 (inclusive) and 1 (exclusive). |
default float |
nextFloat(float bound)
Generates a
float value between 0 (inclusive) and the
specified bound (exclusive). |
default float |
nextFloat(float origin,
float bound)
Generates a
float value between the specified origin (inclusive)
and the specified bound (exclusive). |
default int |
nextInt()
Generates an
int value. |
default int |
nextInt(int n)
Generates an
int value between 0 (inclusive) and the
specified value (exclusive). |
default int |
nextInt(int origin,
int bound)
Generates an
int value between the specified origin (inclusive) and
the specified bound (exclusive). |
long |
nextLong()
Generates a
long value. |
default long |
nextLong(long n)
Generates a
long value between 0 (inclusive) and the specified
value (exclusive). |
default long |
nextLong(long origin,
long bound)
Generates a
long value between the specified origin (inclusive) and
the specified bound (exclusive). |
default void nextBytes(byte[] bytes)
byte
values and places them into a user-supplied array.
The number of random bytes produced is equal to the length of the byte array.
bytes
- Byte array in which to put the random bytes.
Cannot be null
.default void nextBytes(byte[] bytes, int start, int len)
byte
values and places them into a user-supplied array.
The array is filled with bytes extracted from random integers. This implies that the number of random bytes generated may be larger than the length of the byte array.
bytes
- Array in which to put the generated bytes.
Cannot be null
.start
- Index at which to start inserting the generated bytes.len
- Number of bytes to insert.IndexOutOfBoundsException
- if start < 0
or
start >= bytes.length
.IndexOutOfBoundsException
- if len < 0
or
len > bytes.length - start
.default int nextInt()
int
value.default int nextInt(int n)
int
value between 0 (inclusive) and the
specified value (exclusive).n
- Bound on the random number to be returned. Must be positive.int
value between 0 (inclusive) and n
(exclusive).IllegalArgumentException
- if n
is not above zero.default int nextInt(int origin, int bound)
int
value between the specified origin
(inclusive) and
the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.int
value between origin
(inclusive) and
bound
(exclusive).IllegalArgumentException
- if origin
is greater than or equal to
bound
.long nextLong()
long
value.default long nextLong(long n)
long
value between 0 (inclusive) and the specified
value (exclusive).n
- Bound on the random number to be returned. Must be positive.long
value between 0 (inclusive) and n
(exclusive).IllegalArgumentException
- if n
is not greater than 0.default long nextLong(long origin, long bound)
long
value between the specified origin
(inclusive) and
the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.long
value between origin
(inclusive) and
bound
(exclusive).IllegalArgumentException
- if origin
is greater than or equal to
bound
.default boolean nextBoolean()
boolean
value.default float nextFloat()
float
value between 0 (inclusive) and 1 (exclusive).default float nextFloat(float bound)
float
value between 0 (inclusive) and the
specified bound
(exclusive).bound
- Upper bound (exclusive) on the random number to be returned.float
value between 0 (inclusive) and bound
(exclusive).IllegalArgumentException
- if bound
is not both finite and greater than 0.default float nextFloat(float origin, float bound)
float
value between the specified origin
(inclusive)
and the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.float
value between origin
(inclusive) and
bound
(exclusive).IllegalArgumentException
- if origin
is not finite, or bound
is not finite, or origin
is greater than or equal to bound
.default double nextDouble()
double
value between 0 (inclusive) and 1 (exclusive).default double nextDouble(double bound)
double
value between 0 (inclusive) and the
specified bound
(exclusive).bound
- Upper bound (exclusive) on the random number to be returned.double
value between 0 (inclusive) and bound
(exclusive).IllegalArgumentException
- if bound
is not both finite and greater than 0.default double nextDouble(double origin, double bound)
double
value between the specified origin
(inclusive)
and the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.double
value between origin
(inclusive) and
bound
(exclusive).IllegalArgumentException
- if origin
is not finite, or bound
is not finite, or origin
is greater than or equal to bound
.default IntStream ints()
int
values.int
values.default IntStream ints(int origin, int bound)
int
values between the specified
origin
(inclusive) and the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.origin
(inclusive)
and the specified bound
(exclusive).IllegalArgumentException
- if origin
is greater than or equal to
bound
.default IntStream ints(long streamSize)
streamSize
number of int
values.streamSize
- Number of values to generate.int
values; the stream is limited to the given
streamSize
.IllegalArgumentException
- if streamSize
is negative.default IntStream ints(long streamSize, int origin, int bound)
streamSize
number of int
values between the specified origin
(inclusive) and the specified
bound
(exclusive).streamSize
- Number of values to generate.origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.origin
(inclusive)
and the specified bound
(exclusive); the stream is limited to the given
streamSize
.IllegalArgumentException
- if streamSize
is negative, or if
origin
is greater than or equal to bound
.default LongStream longs()
long
values.long
values.default LongStream longs(long origin, long bound)
long
values between the
specified origin
(inclusive) and the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.origin
(inclusive)
and the specified bound
(exclusive).IllegalArgumentException
- if origin
is greater than or equal to
bound
.default LongStream longs(long streamSize)
streamSize
number of long
values.streamSize
- Number of values to generate.long
values; the stream is limited to the given
streamSize
.IllegalArgumentException
- if streamSize
is negative.default LongStream longs(long streamSize, long origin, long bound)
streamSize
number of long
values between the specified origin
(inclusive) and the specified
bound
(exclusive).streamSize
- Number of values to generate.origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.origin
(inclusive)
and the specified bound
(exclusive); the stream is limited to the given
streamSize
.IllegalArgumentException
- if streamSize
is negative, or if
origin
is greater than or equal to bound
.default DoubleStream doubles()
double
values between 0
(inclusive) and 1 (exclusive).default DoubleStream doubles(double origin, double bound)
double
values between the
specified origin
(inclusive) and the specified bound
(exclusive).origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.origin
(inclusive)
and the specified bound
(exclusive).IllegalArgumentException
- if origin
is not finite, or bound
is not finite, or origin
is greater than or equal to bound
.default DoubleStream doubles(long streamSize)
streamSize
number of double
values between 0 (inclusive) and 1 (exclusive).streamSize
- Number of values to generate.streamSize
.IllegalArgumentException
- if streamSize
is negative.default DoubleStream doubles(long streamSize, double origin, double bound)
streamSize
number of double
values between the specified origin
(inclusive) and the specified
bound
(exclusive).streamSize
- Number of values to generate.origin
- Lower bound on the random number to be returned.bound
- Upper bound (exclusive) on the random number to be returned.origin
(inclusive)
and the specified bound
(exclusive); the stream is limited to the given
streamSize
.IllegalArgumentException
- if streamSize
is negative, or if
origin
is not finite, or bound
is not finite, or origin
is
greater than or equal to bound
.Copyright © 2016–2022 The Apache Software Foundation. All rights reserved.