Interface UniformRandomProvider

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default DoubleStream doubles()
      Returns an effectively unlimited stream of double values between 0 (inclusive) and 1 (exclusive).
      default DoubleStream doubles​(double origin, double bound)
      Returns an effectively unlimited stream of double values between the specified origin (inclusive) and the specified bound (exclusive).
      default DoubleStream doubles​(long streamSize)
      Returns a stream producing the given streamSize number of double values between 0 (inclusive) and 1 (exclusive).
      default DoubleStream doubles​(long streamSize, double origin, double bound)
      Returns a stream producing the given streamSize number of double values between the specified origin (inclusive) and the specified bound (exclusive).
      default IntStream ints()
      Returns an effectively unlimited stream of int values.
      default IntStream ints​(int origin, int bound)
      Returns an effectively unlimited stream of int values between the specified origin (inclusive) and the specified bound (exclusive).
      default IntStream ints​(long streamSize)
      Returns a stream producing the given streamSize number of int values.
      default IntStream ints​(long streamSize, int origin, int bound)
      Returns a stream producing the given streamSize number of int values between the specified origin (inclusive) and the specified bound (exclusive).
      default LongStream longs()
      Returns an effectively unlimited stream of long values.
      default LongStream longs​(long streamSize)
      Returns a stream producing the given streamSize number of long values.
      default LongStream longs​(long origin, long bound)
      Returns an effectively unlimited stream of long values between the specified origin (inclusive) and the specified bound (exclusive).
      default LongStream longs​(long streamSize, long origin, long bound)
      Returns a stream producing the given streamSize number of long values between the specified origin (inclusive) and the specified bound (exclusive).
      default boolean nextBoolean()
      Generates a boolean value.
      default void nextBytes​(byte[] bytes)
      Generates byte values and places them into a user-supplied array.
      default void nextBytes​(byte[] bytes, int start, int len)
      Generates byte values and places them into a user-supplied array.
      default double nextDouble()
      Generates a double value between 0 (inclusive) and 1 (exclusive).
      default double nextDouble​(double bound)
      Generates a double value between 0 (inclusive) and the specified bound (exclusive).
      default double nextDouble​(double origin, double bound)
      Generates a double value between the specified origin (inclusive) and the specified bound (exclusive).
      default float nextFloat()
      Generates a float value between 0 (inclusive) and 1 (exclusive).
      default float nextFloat​(float bound)
      Generates a float value between 0 (inclusive) and the specified bound (exclusive).
      default float nextFloat​(float origin, float bound)
      Generates a float value between the specified origin (inclusive) and the specified bound (exclusive).
      default int nextInt()
      Generates an int value.
      default int nextInt​(int n)
      Generates an int value between 0 (inclusive) and the specified value (exclusive).
      default int nextInt​(int origin, int bound)
      Generates an int value between the specified origin (inclusive) and the specified bound (exclusive).
      long nextLong()
      Generates a long value.
      default long nextLong​(long n)
      Generates a long value between 0 (inclusive) and the specified value (exclusive).
      default long nextLong​(long origin, long bound)
      Generates a long value between the specified origin (inclusive) and the specified bound (exclusive).
    • Method Detail

      • nextBytes

        default 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 byte array.

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

        default 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

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

        default 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 not above zero.
      • nextInt

        default int nextInt​(int origin,
                            int bound)
        Generates an int value between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a random int value between origin (inclusive) and bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is greater than or equal to bound.
        Since:
        1.5
      • nextLong

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

        default 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 not greater than 0.
      • nextLong

        default long nextLong​(long origin,
                              long bound)
        Generates a long value between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a random long value between origin (inclusive) and bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is greater than or equal to bound.
        Since:
        1.5
      • nextBoolean

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

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

        default float nextFloat​(float bound)
        Generates a float value between 0 (inclusive) and the specified bound (exclusive).
        Parameters:
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a random float value between 0 (inclusive) and bound (exclusive).
        Throws:
        IllegalArgumentException - if bound is not both finite and greater than 0.
        Since:
        1.5
      • nextFloat

        default float nextFloat​(float origin,
                                float bound)
        Generates a float value between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a random float value between origin (inclusive) and bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
        Since:
        1.5
      • nextDouble

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

        default double nextDouble​(double bound)
        Generates a double value between 0 (inclusive) and the specified bound (exclusive).
        Parameters:
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a random double value between 0 (inclusive) and bound (exclusive).
        Throws:
        IllegalArgumentException - if bound is not both finite and greater than 0.
        Since:
        1.5
      • nextDouble

        default double nextDouble​(double origin,
                                  double bound)
        Generates a double value between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a random double value between origin (inclusive) and bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
        Since:
        1.5
      • ints

        default IntStream ints()
        Returns an effectively unlimited stream of int values.
        Returns:
        a stream of random int values.
        Since:
        1.5
      • ints

        default IntStream ints​(int origin,
                               int bound)
        Returns an effectively unlimited stream of int values between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a stream of random values between the specified origin (inclusive) and the specified bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is greater than or equal to bound.
        Since:
        1.5
      • ints

        default IntStream ints​(long streamSize)
        Returns a stream producing the given streamSize number of int values.
        Parameters:
        streamSize - Number of values to generate.
        Returns:
        a stream of random int values; the stream is limited to the given streamSize.
        Throws:
        IllegalArgumentException - if streamSize is negative.
        Since:
        1.5
      • ints

        default IntStream ints​(long streamSize,
                               int origin,
                               int bound)
        Returns a stream producing the given streamSize number of int values between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        streamSize - Number of values to generate.
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a stream of random values between the specified origin (inclusive) and the specified bound (exclusive); the stream is limited to the given streamSize.
        Throws:
        IllegalArgumentException - if streamSize is negative, or if origin is greater than or equal to bound.
        Since:
        1.5
      • longs

        default LongStream longs()
        Returns an effectively unlimited stream of long values.
        Returns:
        a stream of random long values.
        Since:
        1.5
      • longs

        default LongStream longs​(long origin,
                                 long bound)
        Returns an effectively unlimited stream of long values between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a stream of random values between the specified origin (inclusive) and the specified bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is greater than or equal to bound.
        Since:
        1.5
      • longs

        default LongStream longs​(long streamSize)
        Returns a stream producing the given streamSize number of long values.
        Parameters:
        streamSize - Number of values to generate.
        Returns:
        a stream of random long values; the stream is limited to the given streamSize.
        Throws:
        IllegalArgumentException - if streamSize is negative.
        Since:
        1.5
      • longs

        default LongStream longs​(long streamSize,
                                 long origin,
                                 long bound)
        Returns a stream producing the given streamSize number of long values between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        streamSize - Number of values to generate.
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a stream of random values between the specified origin (inclusive) and the specified bound (exclusive); the stream is limited to the given streamSize.
        Throws:
        IllegalArgumentException - if streamSize is negative, or if origin is greater than or equal to bound.
        Since:
        1.5
      • doubles

        default DoubleStream doubles()
        Returns an effectively unlimited stream of double values between 0 (inclusive) and 1 (exclusive).
        Returns:
        a stream of random values between 0 (inclusive) and 1 (exclusive).
        Since:
        1.5
      • doubles

        default DoubleStream doubles​(double origin,
                                     double bound)
        Returns an effectively unlimited stream of double values between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a stream of random values between the specified origin (inclusive) and the specified bound (exclusive).
        Throws:
        IllegalArgumentException - if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
        Since:
        1.5
      • doubles

        default DoubleStream doubles​(long streamSize)
        Returns a stream producing the given streamSize number of double values between 0 (inclusive) and 1 (exclusive).
        Parameters:
        streamSize - Number of values to generate.
        Returns:
        a stream of random values between 0 (inclusive) and 1 (exclusive); the stream is limited to the given streamSize.
        Throws:
        IllegalArgumentException - if streamSize is negative.
        Since:
        1.5
      • doubles

        default DoubleStream doubles​(long streamSize,
                                     double origin,
                                     double bound)
        Returns a stream producing the given streamSize number of double values between the specified origin (inclusive) and the specified bound (exclusive).
        Parameters:
        streamSize - Number of values to generate.
        origin - Lower bound on the random number to be returned.
        bound - Upper bound (exclusive) on the random number to be returned.
        Returns:
        a stream of random values between the specified origin (inclusive) and the specified bound (exclusive); the stream is limited to the given streamSize.
        Throws:
        IllegalArgumentException - if streamSize is negative, or if origin is not finite, or bound is not finite, or origin is greater than or equal to bound.
        Since:
        1.5