Enum ProviderBuilder.RandomSourceInternal
- All Implemented Interfaces:
Serializable
,Comparable<ProviderBuilder.RandomSourceInternal>
,java.lang.constant.Constable
- Enclosing class:
ProviderBuilder
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionSource of randomness isISAACRandom
.Source of randomness isJDKRandom
.Source of randomness isJenkinsSmallFast32
.Source of randomness isJenkinsSmallFast64
.Source of randomness isKISSRandom
.Source of randomness isL128X1024Mix
.Source of randomness isL128X128Mix
.Source of randomness isL128X256Mix
.Source of randomness isL32X64Mix
.Source of randomness isL64X1024Mix
.Source of randomness isL64X128Mix
.Source of randomness isL64X128StarStar
.Source of randomness isL64X256Mix
.Source of randomness isMiddleSquareWeylSequence
.Source of randomness isMersenneTwister
.Source of randomness isMersenneTwister64
.Source of randomness isMultiplyWithCarry256
.Source of randomness isPcgMcgXshRr32
.Source of randomness isPcgMcgXshRs32
.Source of randomness isPcgRxsMXs64
.Source of randomness isPcgRxsMXs64
.Source of randomness isPcgXshRr32
.Source of randomness isPcgXshRr32
.Source of randomness isPcgXshRs32
.Source of randomness isPcgXshRs32
.Source of randomness isDotyHumphreySmallFastCounting32
.Source of randomness isDotyHumphreySmallFastCounting64
.Source of randomness isSplitMix64
.Source of randomness isTwoCmres
.Source of randomness isTwoCmres
with explicit selection of the two subcycle generators.Source of randomness isWell1024a
.Source of randomness isWell19937a
.Source of randomness isWell19937c
.Source of randomness isWell44497a
.Source of randomness isWell44497b
.Source of randomness isWell512a
.Source of randomness isXoRoShiRo1024PlusPlus
.Source of randomness isXoRoShiRo1024Star
.Source of randomness isXoRoShiRo1024StarStar
.Source of randomness isXoRoShiRo128Plus
.Source of randomness isXoRoShiRo128PlusPlus
.Source of randomness isXoRoShiRo128StarStar
.Source of randomness isXoRoShiRo64Star
.Source of randomness isXoRoShiRo64StarStar
.Source of randomness isXoShiRo128Plus
.Source of randomness isXoShiRo128PlusPlus
.Source of randomness isXoShiRo128StarStar
.Source of randomness isXoShiRo256Plus
.Source of randomness isXoShiRo256PlusPlus
.Source of randomness isXoShiRo256StarStar
.Source of randomness isXoShiRo512Plus
.Source of randomness isXoShiRo512PlusPlus
.Source of randomness isXoShiRo512StarStar
.Source of randomness isXorShift1024Star
.Source of randomness isXorShift1024StarPhi
. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?>[]
Define the parameter types of the data needed to build the generator.private final int
Native seed size.private final NativeSeedType
Native seed type.private final int
Start of the not all-zero sub-range for array seeds (inclusive).private final int
End of the not all-zero sub-range for array seeds (exclusive).private final Class
<? extends UniformRandomProvider> Source type.private Constructor
<?> The constructor. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
RandomSourceInternal
(Class<? extends UniformRandomProvider> rng, int nativeSeedSize, int notAllZeroFrom, int notAllZeroTo, NativeSeedType nativeSeedType, Class<?>... args) Create a new instance.private
RandomSourceInternal
(Class<? extends UniformRandomProvider> rng, int nativeSeedSize, NativeSeedType nativeSeedType, Class<?>... args) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected Object
convertSeed
(Object seed) Converts a seed from any of the supported seed types to a native seed.(package private) RestorableUniformRandomProvider
create()
Creates a RNG instance.(package private) RestorableUniformRandomProvider
Creates a RNG instance.(package private) RestorableUniformRandomProvider
Creates a RNG instance.private static RestorableUniformRandomProvider
create
(Constructor<?> rng, Object[] args) Creates a RNG.protected byte[]
Creates abyte[]
seed using the provided source of randomness.private Constructor
<?> Creates a constructor.private Object
createNativeSeed
(Object seed) Creates a native seed from any of the supported seed types.protected Object
Creates a native seed.final byte[]
Creates a seed suitable for the implementing class represented by this random source.final byte[]
createSeedBytes
(UniformRandomProvider source) Creates a seed suitable for the implementing class represented by this random source using the supplied source of randomness.(package private) Class<?>[]
getArgs()
Gets the parameter types of the data needed to build the generator.private Constructor
<?> Gets the constructor.Class
<?> getRng()
Gets the implementing class of the random source.(package private) Class
<?> getSeed()
Gets the class of the native seed.<SEED> boolean
isNativeSeed
(SEED seed) Checks whether the type of givenseed
is the native type of the implementation.Returns the enum constant of this type with the specified name.static ProviderBuilder.RandomSourceInternal[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
JDK
Source of randomness isJDKRandom
. -
WELL_512_A
Source of randomness isWell512a
. -
WELL_1024_A
Source of randomness isWell1024a
. -
WELL_19937_A
Source of randomness isWell19937a
. -
WELL_19937_C
Source of randomness isWell19937c
. -
WELL_44497_A
Source of randomness isWell44497a
. -
WELL_44497_B
Source of randomness isWell44497b
. -
MT
Source of randomness isMersenneTwister
. -
ISAAC
Source of randomness isISAACRandom
. -
SPLIT_MIX_64
Source of randomness isSplitMix64
. -
XOR_SHIFT_1024_S
Source of randomness isXorShift1024Star
. -
TWO_CMRES
Source of randomness isTwoCmres
. -
TWO_CMRES_SELECT
Source of randomness isTwoCmres
with explicit selection of the two subcycle generators. -
MT_64
Source of randomness isMersenneTwister64
. -
MWC_256
Source of randomness isMultiplyWithCarry256
. -
KISS
Source of randomness isKISSRandom
. -
XOR_SHIFT_1024_S_PHI
Source of randomness isXorShift1024StarPhi
. -
XO_RO_SHI_RO_64_S
Source of randomness isXoRoShiRo64Star
. -
XO_RO_SHI_RO_64_SS
Source of randomness isXoRoShiRo64StarStar
. -
XO_SHI_RO_128_PLUS
Source of randomness isXoShiRo128Plus
. -
XO_SHI_RO_128_SS
Source of randomness isXoShiRo128StarStar
. -
XO_RO_SHI_RO_128_PLUS
Source of randomness isXoRoShiRo128Plus
. -
XO_RO_SHI_RO_128_SS
Source of randomness isXoRoShiRo128StarStar
. -
XO_SHI_RO_256_PLUS
Source of randomness isXoShiRo256Plus
. -
XO_SHI_RO_256_SS
Source of randomness isXoShiRo256StarStar
. -
XO_SHI_RO_512_PLUS
Source of randomness isXoShiRo512Plus
. -
XO_SHI_RO_512_SS
Source of randomness isXoShiRo512StarStar
. -
PCG_XSH_RR_32
Source of randomness isPcgXshRr32
. -
PCG_XSH_RS_32
Source of randomness isPcgXshRs32
. -
PCG_RXS_M_XS_64
Source of randomness isPcgRxsMXs64
. -
PCG_MCG_XSH_RR_32
Source of randomness isPcgMcgXshRr32
. -
PCG_MCG_XSH_RS_32
Source of randomness isPcgMcgXshRs32
. -
MSWS
Source of randomness isMiddleSquareWeylSequence
. -
SFC_32
Source of randomness isDotyHumphreySmallFastCounting32
. -
SFC_64
Source of randomness isDotyHumphreySmallFastCounting64
. -
JSF_32
Source of randomness isJenkinsSmallFast32
. -
JSF_64
Source of randomness isJenkinsSmallFast64
. -
XO_SHI_RO_128_PP
Source of randomness isXoShiRo128PlusPlus
. -
XO_RO_SHI_RO_128_PP
Source of randomness isXoRoShiRo128PlusPlus
. -
XO_SHI_RO_256_PP
Source of randomness isXoShiRo256PlusPlus
. -
XO_SHI_RO_512_PP
Source of randomness isXoShiRo512PlusPlus
. -
XO_RO_SHI_RO_1024_PP
Source of randomness isXoRoShiRo1024PlusPlus
. -
XO_RO_SHI_RO_1024_S
Source of randomness isXoRoShiRo1024Star
. -
XO_RO_SHI_RO_1024_SS
Source of randomness isXoRoShiRo1024StarStar
. -
PCG_XSH_RR_32_OS
Source of randomness isPcgXshRr32
. -
PCG_XSH_RS_32_OS
Source of randomness isPcgXshRs32
. -
PCG_RXS_M_XS_64_OS
Source of randomness isPcgRxsMXs64
. -
L64_X128_SS
Source of randomness isL64X128StarStar
. -
L64_X128_MIX
Source of randomness isL64X128Mix
. -
L64_X256_MIX
Source of randomness isL64X256Mix
. -
L64_X1024_MIX
Source of randomness isL64X1024Mix
. -
L128_X128_MIX
Source of randomness isL128X128Mix
. -
L128_X256_MIX
Source of randomness isL128X256Mix
. -
L128_X1024_MIX
Source of randomness isL128X1024Mix
. -
L32_X64_MIX
Source of randomness isL32X64Mix
.
-
-
Field Details
-
rng
Source type. -
nativeSeedSize
private final int nativeSeedSizeNative seed size. Used for array seeds. -
notAllZeroFrom
private final int notAllZeroFromStart of the not all-zero sub-range for array seeds (inclusive). -
notAllZeroTo
private final int notAllZeroToEnd of the not all-zero sub-range for array seeds (exclusive). -
args
Define the parameter types of the data needed to build the generator. -
nativeSeedType
Native seed type. Used to create a seed or convert input seeds. -
rngConstructor
The constructor. This is discovered using the constructor parameter types and stored for re-use.
-
-
Constructor Details
-
RandomSourceInternal
private RandomSourceInternal(Class<? extends UniformRandomProvider> rng, int nativeSeedSize, NativeSeedType nativeSeedType, Class<?>... args) Create a new instance.Used when the seed array has no requirement for a not all-zero sub-range.
- Parameters:
rng
- Source type.nativeSeedSize
- Native seed size (array types only).nativeSeedType
- Native seed type.args
- Additional data needed to create a generator instance.
-
RandomSourceInternal
private RandomSourceInternal(Class<? extends UniformRandomProvider> rng, int nativeSeedSize, int notAllZeroFrom, int notAllZeroTo, NativeSeedType nativeSeedType, Class<?>... args) Create a new instance.Note: The sub-range of an array seed that is not all-zero can be specified. If the native seed array is used to represent a number of bits that is not an exact multiple of the number of bytes in the seed, then a safe approach is to specify the sub-range using a smaller size than the full length seed. For example a
Well19937a
generator uses 19937 bits and has a seed bit length of 19968. A safe range is [0, 19937 / 32).- Parameters:
rng
- Source type.nativeSeedSize
- Native seed size (array types only).notAllZeroFrom
- The start of the not all-zero sub-range (inclusive).notAllZeroTo
- The end of the not all-zero sub-range (exclusive).nativeSeedType
- Native seed type.args
- Additional data needed to create a generator instance.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getRng
Gets the implementing class of the random source.- Returns:
- the random source class.
-
getSeed
Class<?> getSeed()Gets the class of the native seed.- Returns:
- the seed class.
-
getArgs
Class<?>[] getArgs()Gets the parameter types of the data needed to build the generator.- Returns:
- the data needed to build the generator.
-
isNativeSeed
public <SEED> boolean isNativeSeed(SEED seed) Checks whether the type of givenseed
is the native type of the implementation.- Type Parameters:
SEED
- Seed type.- Parameters:
seed
- Seed value.- Returns:
true
if the seed can be passed to the builder for this RNG type.
-
create
RestorableUniformRandomProvider create()Creates a RNG instance.This method can be over-ridden to allow fast construction of a generator with low seeding cost that has no additional constructor arguments.
- Returns:
- a new RNG instance.
-
create
Creates a RNG instance. It is assumed the seed is notnull
.This method can be over-ridden to allow fast construction of a generator with low seed conversion cost that has no additional constructor arguments.
- Parameters:
seed
- Seed value. It must not benull
.- Returns:
- a new RNG instance.
- Throws:
UnsupportedOperationException
- if the seed type is invalid.
-
create
Creates a RNG instance. This constructs a RNG using reflection and will error if the constructor arguments do not match those required by the RNG's constructor.- Parameters:
seed
- Seed value. It can benull
(in which case a suitable seed will be generated).constructorArgs
- Additional arguments to the implementation's constructor. It must not benull
.- Returns:
- a new RNG instance.
- Throws:
UnsupportedOperationException
- if the seed type is invalid.
-
createSeed
Creates a native seed.The default implementation creates a seed of the native type and, for array seeds, ensures not all bits are zero.
This method should be over-ridden to satisfy seed requirements for the generator.
- Returns:
- the native seed
- Since:
- 1.3
-
createByteArraySeed
Creates abyte[]
seed using the provided source of randomness.The default implementation creates a full-length seed and ensures not all bits are zero.
This method should be over-ridden to satisfy seed requirements for the generator.
- Parameters:
source
- Source of randomness.- Returns:
- the byte[] seed
- Since:
- 1.3
-
convertSeed
Converts a seed from any of the supported seed types to a native seed.The default implementation delegates to the native seed type conversion.
This method should be over-ridden to satisfy seed requirements for the generator.
- Parameters:
seed
- Input seed (must not be null).- Returns:
- the native seed
- Throws:
UnsupportedOperationException
- if theseed
type is invalid.- Since:
- 1.3
-
createNativeSeed
Creates a native seed from any of the supported seed types.- Parameters:
seed
- Input seed (may be null).- Returns:
- the native seed.
- Throws:
UnsupportedOperationException
- if theseed
type cannot be converted.
-
createSeedBytes
public final byte[] createSeedBytes()Creates a seed suitable for the implementing class represented by this random source.It will satisfy the seed size and any other seed requirements for the implementing class. The seed is converted from the native type to bytes.
- Returns:
- the seed bytes
- Since:
- 1.3
-
createSeedBytes
Creates a seed suitable for the implementing class represented by this random source using the supplied source of randomness.It will satisfy the seed size and any other seed requirements for the implementing class. The seed is converted from the native type to bytes.
- Parameters:
source
- Source of randomness.- Returns:
- the seed bytes
- Since:
- 1.3
-
getConstructor
Gets the constructor.- Returns:
- the RNG constructor.
-
createConstructor
Creates a constructor.- Returns:
- a RNG constructor.
-
create
Creates a RNG.- Parameters:
rng
- RNG specification.args
- Arguments to the implementation's constructor.- Returns:
- a new RNG instance.
-