Class Rng

  • All Implemented Interfaces:
    Serializable

    public class Rng
    extends Random
    Simple helper class to generate random numbers.
    Author:
    Tilman Neumann
    See Also:
    Serialized Form
    • Constructor Detail

      • Rng

        public Rng()
    • Method Detail

      • nextInt

        public int nextInt​(int min,
                           int max)
        Creates a random integer from the uniform distribution U[min, max-1]. The only requirements are min >= 0 and max > min.
        Parameters:
        min -
        max -
        Returns:
        random int in the desired range
      • nextLong

        public long nextLong​(long max)
        Creates a random long from the uniform distribution U[0, max-1]. The only requirement is max > 0.
        Parameters:
        max -
        Returns:
        random long in the desired range
      • nextLong

        public long nextLong​(long min,
                             long max)
        Creates a random long from the uniform distribution U[min, max-1]. The only requirements are min >= 0 and max > min.
        Parameters:
        min -
        max -
        Returns:
        random long in the desired range