@Deprecated @FunctionalInterface public interface Extension
enum types, String and BigInteger.
Most methods provide a default implementation that (directly or indirectly) uses nextBits(int).
The latter is the only method without a default implementation.
This interface is primarily intended to extend a derivation of Random with basic methods, example:
import de.team33.patterns.random.mimas.Extension;
import java.math.BigInteger;
import java.util.Random;
public class XRandom extends Random implements Extension {
@Override
public final BigInteger nextBits(final int numBits) {
return new BigInteger(numBits, this);
}
}
In such a use case, some of the default implementations will be overwritten by existing implementations from
Random.
However, it can also be used in other ways. In particular, deterministic implementations are also conceivable.
| Modifier and Type | Method and Description |
|---|---|
default BigInteger |
nextBigInteger(BigInteger bound)
Deprecated.
Returns a
BigInteger value between ZERO (incl.) and bound (excl.). |
default BigInteger |
nextBigInteger(BigInteger min,
BigInteger bound)
Deprecated.
|
BigInteger |
nextBits(int numBits)
Deprecated.
Returns any non-negative
BigInteger representing a sequence of significant bits of a given length. |
default boolean |
nextBoolean()
Deprecated.
Returns any
boolean value. |
default byte |
nextByte()
Deprecated.
Returns any
byte value. |
default char |
nextChar(String characters)
Deprecated.
Returns any
char value of the given characters. |
default double |
nextDouble()
Deprecated.
Returns a
double value between zero (incl.) and one (excl.). |
default float |
nextFloat()
Deprecated.
Returns a
float value between zero (incl.) and one (excl.). |
default int |
nextInt()
Deprecated.
Returns any
int value. |
default int |
nextInt(int bound)
Deprecated.
Returns an
int value between zero (incl.) and bound (excl.). |
default int |
nextInt(int min,
int bound)
Deprecated.
Returns an
int value between min (incl.) and bound (excl.). |
default long |
nextLong()
Deprecated.
Returns any
long value. |
default long |
nextLong(long bound)
Deprecated.
Returns any
long value between zero (incl.) and bound (excl.). |
default long |
nextLong(long min,
long bound)
Deprecated.
Returns any
long value between min (incl.) and bound (excl.). |
default <T extends Enum<T>> |
nextOf(Class<T> enumClass)
Deprecated.
Returns one of the given
enum values. |
default <T> T |
nextOf(T... values)
Deprecated.
Returns one of the given
values. |
default short |
nextShort()
Deprecated.
Returns any
short value. |
default String |
nextString(int length,
String characters)
Deprecated.
|
BigInteger nextBits(int numBits)
BigInteger representing a sequence of significant bits of a given length.
In other words, the result is any value between zero (inclusive) and 2length (exclusive).
A typical implementation will return a random value within the defined bounds, with each possible value being equally probable.
default boolean nextBoolean()
boolean value.
The default implementation depends on the implementation of nextBits(int).
When used as extension of a Random derivation, this method will (at least) be overridden by
Random.nextBoolean().
default byte nextByte()
byte value.
The default implementation depends on the implementation of nextBits(int).
default short nextShort()
short value.
The default implementation depends on the implementation of nextBits(int).
default int nextInt()
int value.
The default implementation depends on the implementation of nextBits(int).
When used as extension of a Random derivation, this method will (at least) be overridden by
Random.nextInt().
default int nextInt(int bound)
int value between zero (incl.) and bound (excl.).
The default implementation depends on the implementation of nextBigInteger(BigInteger).
When used as extension of a Random derivation, this method will (at least) be overridden by
Random.nextInt(int).
default int nextInt(int min,
int bound)
int value between min (incl.) and bound (excl.).
The default implementation depends on the implementation of nextBigInteger(BigInteger, BigInteger).
default long nextLong()
long value.
The default implementation depends on the implementation of nextBits(int).
When used as extension of a Random derivation, this method will (at least) be overridden by
Random.nextLong().
default long nextLong(long bound)
long value between zero (incl.) and bound (excl.).
The default implementation depends on the implementation of nextBigInteger(BigInteger).
default long nextLong(long min,
long bound)
long value between min (incl.) and bound (excl.).
The default implementation depends on the implementation of nextBigInteger(BigInteger, BigInteger).
default float nextFloat()
float value between zero (incl.) and one (excl.).
The default implementation depends on the implementation of nextBits(int).
When used as extension of a Random derivation, this method will (at least) be overridden by
Random.nextFloat().
default double nextDouble()
double value between zero (incl.) and one (excl.).
The default implementation depends on the implementation of nextBits(int).
When used as extension of a Random derivation, this method will (at least) be overridden by
Random.nextDouble().
default char nextChar(String characters)
char value of the given characters.
The default implementation depends on the implementation of nextInt(int).
characters - A String made up of the characters that are a possible result.default String nextString(int length, String characters)
String with the given length consisting of the given characters.
The default implementation depends on the implementation of nextInt(int).
length - The length of the resulting string.characters - A string made up of the characters that make up a possible result.default BigInteger nextBigInteger(BigInteger bound)
BigInteger value between ZERO (incl.) and bound (excl.).
The default implementation depends on the implementation of nextBits(int).
default BigInteger nextBigInteger(BigInteger min, BigInteger bound)
BigInteger value between min (incl.) and bound (excl.).
The default implementation depends on the implementation of nextBigInteger(BigInteger).
default <T> T nextOf(T... values)
values.
The default implementation depends on the implementation of nextInt(int).
default <T extends Enum<T>> T nextOf(Class<T> enumClass)
enum values.
The default implementation depends on the implementation of nextOf(Object[]).
Copyright © 2023 Andreas Kluge-Kaindl, Bremen (de). All rights reserved.