RandomGenerator

interface RandomGenerator

An interface that is implemented by random number generator algorithms.

Types

Companion
Link copied to clipboard
common
object Companion

Functions

fillBytes
Link copied to clipboard
common
abstract fun fillBytes(array: ByteArray, fromIndex: Int = 0, toIndex: Int = array.size)
Fills a subrange with the specified byte array starting from fromIndex inclusive and ending toIndex exclusive with random bytes.
fork
Link copied to clipboard
common
abstract fun fork(): RandomGenerator
Create a new generator that is independent of current generator (operations on new generator do not affect this one and vise versa).
nextBoolean
Link copied to clipboard
common
abstract fun nextBoolean(): Boolean
Gets the next random Boolean value.
nextBytes
Link copied to clipboard
common
open fun nextBytes(size: Int): ByteArray
Creates a byte array of the specified size, filled with random bytes.
nextDouble
Link copied to clipboard
common
abstract fun nextDouble(): Double
Gets the next random Double value uniformly distributed between 0 (inclusive) and 1 (exclusive).
nextDoubleBuffer
Link copied to clipboard
common
open fun nextDoubleBuffer(size: Int): DoubleBuffer
A chunk of doubles of given size.
nextInt
Link copied to clipboard
common
abstract fun nextInt(): Int
Gets the next random Int from the random number generator.
abstract fun nextInt(until: Int): Int
Gets the next random non-negative Int from the random number generator less than the specified until bound.
nextLong
Link copied to clipboard
common
abstract fun nextLong(): Long
Gets the next random Long from the random number generator.
abstract fun nextLong(until: Long): Long
Gets the next random non-negative Long from the random number generator less than the specified until bound.

Inheritors

DefaultGenerator
Link copied to clipboard
RandomSourceGenerator
Link copied to clipboard

Extensions

asUniformRandomProvider
Link copied to clipboard
fun RandomGenerator.asUniformRandomProvider(): UniformRandomProvider
Represent this RandomGenerator as commons-rng UniformRandomProvider preserving and mirroring its current state.
chain
Link copied to clipboard
common
fun <R> RandomGenerator.chain(generator: suspend RandomGenerator.() -> R): RandomChain<R>
Create a generic random chain with provided generator

Sources

common source
Link copied to clipboard