An interface for random number generators. Satisfying classes must implement nextBits(), which is used by the default implementations of the methods of this interface.

By: John Vasileff

no type hierarchy

no supertypes hierarchy

Inherited Attributes
Attributes inherited from: Object
Methods
bitsSource Codeshared {Integer+} bits(Integer bits)

Return an infinite stream of Integers holding bits pseudorandom bits.

See also nextBits()
booleansSource Codeshared {Boolean+} booleans()

Return an infinite stream of pseudorandom Booleans.

See also nextBoolean()
bytesSource Codeshared {Byte+} bytes()

Return an infinite stream of pseudorandom Bytes.

See also nextByte()
elementsSource Codeshared Iterable<Element,Absent> elements<Element, Absent>(Iterable<Element,Absent> stream)
given Element satisfies Object
given Absent satisfies Null

Returns an infinite stream of random elements from the given stream. The stream is eagerly evaluated a single time using Iterable.sequence(), with random elements being selected from the result of that evaluation.

The result will be empty if the provided stream is empty.

See also nextElement()
floatsSource Codeshared {Float+} floats()

Return an infinite stream of pseudorandom Floats.

See also nextFloat()
integersSource Codeshared {Integer+} integers(Integer bound)

Return an infinite stream of pseudorandom Integers between 0 (inclusive) and bound (exclusive).

Parameters:
  • bound

    The upper bound (exclusive).

See also nextInteger()
nextBitsSource Codeshared formal Integer nextBits(Integer bits)

Generates an Integer holding bits pseudorandom bits. The returned value will be:

  • equal to 0 for bits <= 0
  • in the range 0..(2^n - 1) for bits in 1..63
  • in the range -2^63..(2^63 - 1) for bits == 64

Note that bits may not be greater than randomLimits.maxBits.

Parameters:
  • bits

    The number of psuedorandom bits to generate

Throws
See also bits()
nextBooleanSource Codeshared default Boolean nextBoolean()

Returns the next pseudorandom Boolean.

See also booleans()
nextByteSource Codeshared default Byte nextByte()

Returns the next pseudorandom Byte.

See also bytes()
nextElementSource Codeshared default Element|Absent nextElement<Element, Absent>(Iterable<Element,Absent> stream)
given Element satisfies Object
given Absent satisfies Null

Returns a random element from the supplied Iterable. Useful argument types include Sequences, such as ["heads", "tails"], and Ranges, such as [1:100] or ['A'..'Z'].

See also elements()
nextFloatSource Codeshared default Float nextFloat()

Returns the next pseudorandom Float between 0.0 and 1.0.

See also floats()
nextIntegerSource Codeshared default Integer nextInteger(Integer bound)

Returns the next pseudorandom Integer between 0 (inclusive) and bound (exclusive).

Parameters:
  • bound

    The upper bound (exclusive).

Throws
See also integers()
Inherited Methods
Methods inherited from: Object