Class BaseSplittableRandomAdapter

    • Constructor Detail

      • BaseSplittableRandomAdapter

        protected BaseSplittableRandomAdapter​(byte[] seed)
        Constructs an instance with the given seed.
        Parameters:
        seed - The seed.
      • BaseSplittableRandomAdapter

        protected BaseSplittableRandomAdapter​(long seed)
        Constructs an instance with the given seed.
        Parameters:
        seed - The seed.
    • Method Detail

      • getSplittableRandom

        protected abstract java8.util.SplittableRandom getSplittableRandom()
        Returns the SplittableRandom that is to be used to generate random numbers for the current thread. (SplittableRandom isn't thread-safe.) Called by all the next* methods.
        Returns:
        the SplittableRandom to use with the current thread.
      • nextDouble

        public double nextDouble​(double bound)
        Delegates to SplittableRandom.nextDouble(bound).
        Overrides:
        nextDouble in class BaseRandom
        Parameters:
        bound - the upper bound (exclusive). Must be positive.
        Returns:
        a pseudorandom double value between zero (inclusive) and the bound (exclusive)
      • nextDouble

        public double nextDouble​(double origin,
                                 double bound)
        Delegates to SplittableRandom.nextDouble (origin, bound).
        Overrides:
        nextDouble in class BaseRandom
        Parameters:
        origin - the least value returned
        bound - the upper bound (exclusive)
        Returns:
        a pseudorandom double value between the origin (inclusive) and the bound (exclusive)
      • next

        protected int next​(int bits)
        Delegates to SplittableRandom.nextInt() or SplittableRandom.nextInt(int).
        Specified by:
        next in class BaseRandom
      • nextInt

        public int nextInt​(int origin,
                           int bound)
        Delegates to SplittableRandom.nextInt(origin, bound).
        Overrides:
        nextInt in class BaseRandom
        Parameters:
        origin - the least value returned
        bound - the upper bound (exclusive)
        Returns:
        a pseudorandom int value between the origin (inclusive) and the bound (exclusive)
      • withProbabilityInternal

        protected boolean withProbabilityInternal​(double probability)

        Delegates to SplittableRandom.nextDouble().

        Called by BaseRandom.withProbability(double) to generate a boolean with a specified probability of returning true, after checking that probability is strictly between 0 and 1.
        Overrides:
        withProbabilityInternal in class BaseRandom
        Parameters:
        probability - The probability (between 0 and 1 exclusive) of returning true.
        Returns:
        True with probability equal to the probability parameter; false otherwise.
      • nextLongNoEntropyDebit

        protected long nextLongNoEntropyDebit()

        Delegates to SplittableRandom.nextLong().

        Returns the next random long, but does not debit entropy.
        Overrides:
        nextLongNoEntropyDebit in class BaseRandom
        Returns:
        a pseudorandom long with all possible values equally likely.
      • nextLong

        public long nextLong​(long bound)
        Delegates to SplittableRandom.nextLong(bound).
        Overrides:
        nextLong in class BaseRandom
        Parameters:
        bound - the upper bound (exclusive). Must be positive.
        Returns:
        a pseudorandom long value between zero (inclusive) and the bound (exclusive)
      • nextLong

        public long nextLong​(long origin,
                             long bound)
        Delegates to SplittableRandom.nextLong(origin, bound).
        Overrides:
        nextLong in class BaseRandom
        Parameters:
        origin - the least value returned
        bound - the upper bound (exclusive)
        Returns:
        a pseudorandom long value between the origin (inclusive) and the bound (exclusive)
      • nextDoubleNoEntropyDebit

        protected double nextDoubleNoEntropyDebit()
        Delegates to SplittableRandom.nextDouble().
        Overrides:
        nextDoubleNoEntropyDebit in class BaseRandom
        Returns:
        a pseudorandom double.