Class DirectSplittableRandomAdapter
- 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
 
 
 
 
 
- 
- All Implemented Interfaces:
 ByteArrayReseedableRandom,EntropyCountingRandom,Java8CompatRandom,RepeatableRandom,Dumpable,Serializable
- Direct Known Subclasses:
 SingleThreadSplittableRandomAdapter
public abstract class DirectSplittableRandomAdapter extends BaseSplittableRandomAdapter
Abstract subclass ofBaseSplittableRandomAdapterwheresetSeed(long)andBaseRandom.setSeed(byte[])replace theSplittableRandomthat's used in the context in which they are called. SeeSplittableRandomAdapterfor an example of when it does not make sense to extend this class.- Author:
 - Chris Hennick
 - See Also:
 - Serialized Form
 
 
- 
- 
Field Summary
Fields Modifier and Type Field Description protected java8.util.SplittableRandomdelegateThe masterSplittableRandomthat will either be delegated to directly (seeSingleThreadSplittableRandomAdapteror be split usingSplittableRandom.split()(seeSplittableRandomAdapter) and have the splits delegated to.- 
Fields inherited from class io.github.pr0methean.betterrandom.prng.BaseRandom
ENTROPY_OF_DOUBLE, ENTROPY_OF_FLOAT, entropyBits, lock, randomSeeder, seed, superConstructorFinished 
 - 
 
- 
Constructor Summary
Constructors Modifier Constructor Description protectedDirectSplittableRandomAdapter(byte[] seed)Wraps aSplittableRandomwith the specified seed.protectedDirectSplittableRandomAdapter(long seed)Wraps aSplittableRandomwith the specified seed. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected MoreObjects.ToStringHelperaddSubclassFields(MoreObjects.ToStringHelper original)Adds the fields that were not inherited from BaseRandom to the givenMoreObjects.ToStringHelperfor dumping.voidsetSeed(long seed)Replaces the delegate with a newSplittableRandomthat uses the given seed.protected voidsetSeedInternal(byte[] seed)Replaces the delegate with a newSplittableRandomthat uses the given seed.- 
Methods inherited from class io.github.pr0methean.betterrandom.prng.adapter.BaseSplittableRandomAdapter
getNewSeedLength, getSplittableRandom, 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, debitEntropy, 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 
 - 
 
 - 
 
- 
- 
Field Detail
- 
delegate
protected transient volatile java8.util.SplittableRandom delegate
The masterSplittableRandomthat will either be delegated to directly (seeSingleThreadSplittableRandomAdapteror be split usingSplittableRandom.split()(seeSplittableRandomAdapter) and have the splits delegated to. 
 - 
 
- 
Constructor Detail
- 
DirectSplittableRandomAdapter
protected DirectSplittableRandomAdapter(byte[] seed)
Wraps aSplittableRandomwith the specified seed.- Parameters:
 seed- 8 bytes of seed data used to initialize the RNG.
 
- 
DirectSplittableRandomAdapter
protected DirectSplittableRandomAdapter(long seed)
Wraps aSplittableRandomwith the specified seed.- Parameters:
 seed- the seed.
 
 - 
 
- 
Method Detail
- 
addSubclassFields
protected MoreObjects.ToStringHelper addSubclassFields(MoreObjects.ToStringHelper original)
Description copied from class:BaseRandomAdds the fields that were not inherited from BaseRandom to the givenMoreObjects.ToStringHelperfor dumping.- Specified by:
 addSubclassFieldsin classBaseRandom- Parameters:
 original- aMoreObjects.ToStringHelperobject.- Returns:
 originalwith the fields not inherited from BaseRandom written to it.
 
- 
setSeedInternal
protected void setSeedInternal(byte[] seed)
Replaces the delegate with a newSplittableRandomthat uses the given seed.- Overrides:
 setSeedInternalin classBaseRandom- Parameters:
 seed- the new seed; must be 8 bytes
 
- 
setSeed
public void setSeed(long seed)
Replaces the delegate with a newSplittableRandomthat uses the given seed.- Specified by:
 setSeedin interfaceJava8CompatRandom- Overrides:
 setSeedin classBaseRandom- Parameters:
 seed- the new seed
 
 - 
 
 -