Class SplitMix64Random

  • All Implemented Interfaces:
    Serializable

    public class SplitMix64Random
    extends Random
    A fast, high-quality, non-splittable version of the SplitMix pseudorandom number generator used by SplittableRandom. Due to the fixed increment constant and to different strategies in generating finite ranges, the methods of this generator are usually faster than those of SplittableRandom.

    Note that this generator has a relatively short period (264) so it should not be used to generate very long sequences (the rule of thumb to have a period greater than the square of the length of the sequence you want to generate).

    See Also:
    it.unimi.dsi.util, Random, SplitMix64RandomGenerator, Serialized Form
    • Constructor Detail

      • SplitMix64Random

        public SplitMix64Random()
        Creates a new generator seeded using Util.randomSeed().
      • SplitMix64Random

        public SplitMix64Random​(long seed)
        Creates a new generator using a given seed.
        Parameters:
        seed - a seed for the generator.
    • Method Detail

      • nextLong

        public long nextLong()
        Overrides:
        nextLong in class Random
      • nextInt

        public int nextInt()
        Overrides:
        nextInt in class Random
      • nextInt

        public int nextInt​(int n)
        Overrides:
        nextInt in class Random
      • nextLong

        public long nextLong​(long n)
        Returns a pseudorandom uniformly distributed long value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence. The algorithm used to generate the value guarantees that the result is uniform, provided that the sequence of 64-bit values produced by this generator is.
        Parameters:
        n - the positive bound on the random number to be returned.
        Returns:
        the next pseudorandom long value between 0 (inclusive) and n (exclusive).
      • nextDouble

        public double nextDouble()
        Overrides:
        nextDouble in class Random
      • nextFloat

        public float nextFloat()
        Overrides:
        nextFloat in class Random
      • nextBoolean

        public boolean nextBoolean()
        Overrides:
        nextBoolean in class Random
      • nextBytes

        public void nextBytes​(byte[] bytes)
        Overrides:
        nextBytes in class Random
      • setSeed

        public void setSeed​(long seed)
        Sets the seed of this generator.

        The seed will be passed through HashCommon.murmurHash3(long).

        Overrides:
        setSeed in class Random
        Parameters:
        seed - a seed for this generator.
      • setState

        public void setState​(long state)
        Sets the state of this generator.
        Parameters:
        state - the new state for this generator (must be nonzero).