Class SingleThreadSplittableRandomAdapter
- java.lang.Object
-
- java.util.Random
-
- io.github.pr0methean.betterrandom.prng.BaseRandom
-
- io.github.pr0methean.betterrandom.prng.adapter.BaseSplittableRandomAdapter
-
- io.github.pr0methean.betterrandom.prng.adapter.DirectSplittableRandomAdapter
-
- io.github.pr0methean.betterrandom.prng.adapter.SingleThreadSplittableRandomAdapter
-
- All Implemented Interfaces:
ByteArrayReseedableRandom
,EntropyCountingRandom
,Java8CompatRandom
,RepeatableRandom
,Dumpable
,Serializable
public class SingleThreadSplittableRandomAdapter extends DirectSplittableRandomAdapter
Simple, non-thread-safe implementation ofBaseRandom
that wraps aSplittableRandom
.- Author:
- Chris Hennick
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class io.github.pr0methean.betterrandom.prng.adapter.DirectSplittableRandomAdapter
delegate
-
Fields inherited from class io.github.pr0methean.betterrandom.prng.BaseRandom
ENTROPY_OF_DOUBLE, ENTROPY_OF_FLOAT, entropyBits, lock, randomSeeder, seed, superConstructorFinished
-
-
Constructor Summary
Constructors Constructor Description SingleThreadSplittableRandomAdapter()
Use theDefaultSeedGenerator
to create the seed for theSplittableRandom
.SingleThreadSplittableRandomAdapter(byte[] seed)
Use the provided seed for theSplittableRandom
.SingleThreadSplittableRandomAdapter(long seed)
Use the provided seed for theSplittableRandom
.SingleThreadSplittableRandomAdapter(SeedGenerator seedGenerator)
Use the provided seed generation strategy to create the seed for theSplittableRandom
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
debitEntropy(long bits)
Must be redeclared in this package so thatSplittableRandomAdapter
can access it.protected java8.util.SplittableRandom
getSplittableRandom()
Returns this SingleThreadSplittableRandomAdapter's onlySplittableRandom
.-
Methods inherited from class io.github.pr0methean.betterrandom.prng.adapter.DirectSplittableRandomAdapter
addSubclassFields, setSeed, setSeedInternal
-
Methods inherited from class io.github.pr0methean.betterrandom.prng.adapter.BaseSplittableRandomAdapter
getNewSeedLength, lockForNextGaussian, next, nextBoolean, nextBytes, nextDouble, nextDouble, nextDoubleNoEntropyDebit, nextFloat, nextGaussian, nextInt, nextInt, nextInt, nextLong, nextLong, nextLongNoEntropyDebit, preferSeedWithLong, unlockForNextGaussian, withProbabilityInternal
-
Methods inherited from class io.github.pr0methean.betterrandom.prng.BaseRandom
checkLength, creditEntropyForNewSeed, doubles, doubles, doubles, doubles, dump, entropyOfInt, entropyOfLong, fallbackSetSeedIfInitialized, gaussians, gaussians, getEntropyBits, getRandomSeeder, getSeed, initTransientFields, internalNextGaussian, ints, ints, ints, ints, longs, longs, longs, longs, needsReseedingEarly, nextDouble, nextElement, nextElement, nextEnum, nextLong, setRandomSeeder, setSeed, supportsMultipleSeedLengths, usesParallelStreams, withProbability
-
-
-
-
Constructor Detail
-
SingleThreadSplittableRandomAdapter
public SingleThreadSplittableRandomAdapter(SeedGenerator seedGenerator) throws SeedException
Use the provided seed generation strategy to create the seed for theSplittableRandom
.- Parameters:
seedGenerator
- The seed generation strategy that will provide the seed value for this RNG.- Throws:
SeedException
- if there is a problem generating a seed.
-
SingleThreadSplittableRandomAdapter
public SingleThreadSplittableRandomAdapter() throws SeedException
Use theDefaultSeedGenerator
to create the seed for theSplittableRandom
.- Throws:
SeedException
- if theDefaultSeedGenerator
fails to generate a seed.
-
SingleThreadSplittableRandomAdapter
public SingleThreadSplittableRandomAdapter(byte[] seed)
Use the provided seed for theSplittableRandom
.- Parameters:
seed
- The seed. Must be 8 bytes.
-
SingleThreadSplittableRandomAdapter
public SingleThreadSplittableRandomAdapter(long seed)
Use the provided seed for theSplittableRandom
.- Parameters:
seed
- The seed.
-
-
Method Detail
-
debitEntropy
protected void debitEntropy(long bits)
Must be redeclared in this package so thatSplittableRandomAdapter
can access it.- Overrides:
debitEntropy
in classBaseRandom
- Parameters:
bits
- The number of bits of entropy spent.
-
getSplittableRandom
protected java8.util.SplittableRandom getSplittableRandom()
Returns this SingleThreadSplittableRandomAdapter's onlySplittableRandom
.- Specified by:
getSplittableRandom
in classBaseSplittableRandomAdapter
- Returns:
- the SplittableRandom
-
-