Interface UniformRandomProvider

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean nextBoolean()
      Generates a boolean value.
      void nextBytes​(byte[] bytes)
      Generates byte values and places them into a user-supplied array.
      void nextBytes​(byte[] bytes, int start, int len)
      Generates byte values and places them into a user-supplied array.
      double nextDouble()
      Generates a double value between 0 and 1.
      float nextFloat()
      Generates a float value between 0 and 1.
      int nextInt()
      Generates an int value.
      int nextInt​(int n)
      Generates an int value between 0 (inclusive) and the specified value (exclusive).
      long nextLong()
      Generates a long value.
      long nextLong​(long n)
      Generates a long value between 0 (inclusive) and the specified value (exclusive).
    • Method Detail

      • nextBytes

        void nextBytes​(byte[] bytes)
        Generates byte values and places them into a user-supplied array.

        The number of random bytes produced is equal to the length of the the byte array.

        Parameters:
        bytes - Byte array in which to put the random bytes. Cannot be null.
      • nextBytes

        void nextBytes​(byte[] bytes,
                       int start,
                       int len)
        Generates byte values and places them into a user-supplied array.

        The array is filled with bytes extracted from random integers. This implies that the number of random bytes generated may be larger than the length of the byte array.

        Parameters:
        bytes - Array in which to put the generated bytes. Cannot be null.
        start - Index at which to start inserting the generated bytes.
        len - Number of bytes to insert.
        Throws:
        IndexOutOfBoundsException - if start < 0 or start >= bytes.length.
        IndexOutOfBoundsException - if len < 0 or len > bytes.length - start.
      • nextInt

        int nextInt()
        Generates an int value.
        Returns:
        the next random value.
      • nextInt

        int nextInt​(int n)
        Generates an int value between 0 (inclusive) and the specified value (exclusive).
        Parameters:
        n - Bound on the random number to be returned. Must be positive.
        Returns:
        a random int value between 0 (inclusive) and n (exclusive).
        Throws:
        IllegalArgumentException - if n is negative.
      • nextLong

        long nextLong()
        Generates a long value.
        Returns:
        the next random value.
      • nextLong

        long nextLong​(long n)
        Generates a long value between 0 (inclusive) and the specified value (exclusive).
        Parameters:
        n - Bound on the random number to be returned. Must be positive.
        Returns:
        a random long value between 0 (inclusive) and n (exclusive).
        Throws:
        IllegalArgumentException - if n is negative.
      • nextBoolean

        boolean nextBoolean()
        Generates a boolean value.
        Returns:
        the next random value.
      • nextFloat

        float nextFloat()
        Generates a float value between 0 and 1.
        Returns:
        the next random value between 0 and 1.
      • nextDouble

        double nextDouble()
        Generates a double value between 0 and 1.
        Returns:
        the next random value between 0 and 1.