Module gomint.api

Class FastRandom

    • Constructor Detail

      • FastRandom

        public FastRandom()
        Generate a new fast random with System.nanoTime() as seed
      • FastRandom

        public FastRandom​(long seed)
        Generate new fast random with given seed
        Parameters:
        seed - the initial seed
    • Method Detail

      • setSeed

        public void setSeed​(long seed)
        Set the seed of this random
        Overrides:
        setSeed in class Random
        Parameters:
        seed - which should be used
      • next

        protected int next​(int nbits)
        Implementation of George Marsaglia's elegant Xorshift random generator 30% faster and better quality than the built-in java.util.random see also see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml
        Overrides:
        next in class Random
        Parameters:
        nbits - number of bits to generate
        Returns:
        randomized number of bits length
      • current

        public static FastRandom current()
        Thread safe fast random access
        Returns:
        a per thread instance of the fast random