Package-level declarations

Functions

Link copied to clipboard
@JvmName(name = "choiceVararg")
fun <T> Random.choice(vararg elements: T): T
fun <T> Random.choice(array: Array<T>): T

Returns a random element from this array using the specified source of randomness.

fun <T> Random.choice(collection: Collection<T>): T

Returns a random element from this collection using the specified source of randomness.

inline fun <T, K> Random.choice(map: Map<T, K>): Pair<T, K>

Returns a random element from this map using the specified source of randomness.

Link copied to clipboard
fun <T> Random.choiceOrNull(array: Array<T>): T?

Returns a random element from this array using the specified source of randomness, or null if this array is empty.

fun <T> Random.choiceOrNull(collection: Collection<T>): T?

Returns a random element from this collection using the specified source of randomness, or null if this collection is empty.

inline fun <T, K> Random.choiceOrNull(map: Map<T, K>): Pair<T, K>?

Returns a random element from this map using the specified source of randomness, or null if this map is empty.

Link copied to clipboard
@JvmName(name = "choicesVararg")
@JvmOverloads
fun <T> Random.choices(vararg elements: T, weights: List<Int>? = null, length: Int = 1): List<T>
@JvmOverloads
fun <T> Random.choices(array: Array<T>, weights: List<Int>? = null, length: Int = 1): List<T>

Returns a random list from this array using the specified source of randomness.

@JvmOverloads
fun <T> Random.choices(collection: Collection<T>, weights: List<Int>? = null, length: Int = 1): List<T>

Returns a random list from this collection using the specified source of randomness.

Link copied to clipboard
@JvmOverloads
fun <T> Random.choicesOrNull(array: Array<T>, weights: List<Int>? = null, length: Int = 1): List<T>?

Returns a random list from this array using the specified source of randomness, or null if this array is empty.

@JvmOverloads
fun <T> Random.choicesOrNull(collection: Collection<T>, weights: List<Int>? = null, length: Int = 1): List<T>?

Returns a random list from this collection using the specified source of randomness, or null if this collection is empty.

Link copied to clipboard
fun Random.nextInt(progression: IntProgression): Int

Gets the next random Int from the random number generator in the specified progression. Generates an Int random value uniformly distributed in the specified progression.

Link copied to clipboard
fun Random.nextLong(progression: LongProgression): Long

Gets the next random Long from the random number generator in the specified progression. Generates a Long random value uniformly distributed in the specified progression.

Link copied to clipboard
fun Random.nextUInt(progression: UIntProgression): UInt

Gets the next random UInt from the random number generator in the specified progression. Generates an UInt random value uniformly distributed in the specified progression.

Link copied to clipboard
fun Random.nextULong(progression: ULongProgression): ULong

Gets the next random ULong from the random number generator in the specified progression. Generates a ULong random value uniformly distributed in the specified progression.

Link copied to clipboard
inline fun <K, V> Map<K, V>.random(): Pair<K, V>

Returns a random element from this map using the specified source of randomness.

Link copied to clipboard
inline fun <K, V> Map<K, V>.randomOrNull(): Pair<K, V>?

Returns a random element from this map using the specified source of randomness, or null if this map is empty.