Class RandomNumberGenerator

java.lang.Object
rosequartz.rng.RandomNumberGenerator

public final class RandomNumberGenerator extends Object
Class used to generate random numbers.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RandomNumberGenerator​(long seed)
    Creates a random number generator from a seed to use.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    getDouble​(double min, double max)
    Generates a completely random number and returns it as a double in the specified range.
    static float
    getFloat​(float min, float max)
    Generates a completely random number and returns it as a float in the specified range.
    static int
    getInt​(int min, int max)
    Generates a completely random number and returns it as an integer in the specified range.
    long
    Gets the current seed used to generate from.
    double
    nextDouble​(double min, double max)
    Generates the next number and returns it as a double in the specified range.
    float
    nextFloat​(float min, float max)
    Generates the next number and returns it as a float in the specified range.
    int
    nextInt​(int min, int max)
    Generates the next number and returns it as an integer in the specified range.
    setSeed​(long seed)
    Sets the seed to generate from.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RandomNumberGenerator

      public RandomNumberGenerator(long seed)
      Creates a random number generator from a seed to use.
      Parameters:
      seed - the seed to generate from
  • Method Details

    • getInt

      public static int getInt(int min, int max)
      Generates a completely random number and returns it as an integer in the specified range.
      Parameters:
      min - smallest possible result
      max - largest possible result
      Returns:
      result
    • getFloat

      public static float getFloat(float min, float max)
      Generates a completely random number and returns it as a float in the specified range.
      Parameters:
      min - smallest possible result
      max - largest possible result
      Returns:
      result
    • getDouble

      public static double getDouble(double min, double max)
      Generates a completely random number and returns it as a double in the specified range.
      Parameters:
      min - smallest possible result
      max - largest possible result
      Returns:
      result
    • setSeed

      public RandomNumberGenerator setSeed(long seed)
      Sets the seed to generate from.
      Parameters:
      seed - seed to use
      Returns:
      this
    • getSeed

      public long getSeed()
      Gets the current seed used to generate from.
      Returns:
      current seed
    • nextInt

      public int nextInt(int min, int max)
      Generates the next number and returns it as an integer in the specified range.
      Parameters:
      min - smallest possible result
      max - largest possible result
      Returns:
      result
    • nextFloat

      public float nextFloat(float min, float max)
      Generates the next number and returns it as a float in the specified range.
      Parameters:
      min - smallest possible result
      max - largest possible result
      Returns:
      result
    • nextDouble

      public double nextDouble(double min, double max)
      Generates the next number and returns it as a double in the specified range.
      Parameters:
      min - smallest possible result
      max - largest possible result
      Returns:
      result