Seed

sealed class Seed : Comparable<Seed>

Represents a seed value for generating randomization in various contexts.

Seed values are typically used to control the starting point of a random sequence, ensuring reproducibility and consistency across different runs. This sealed class provides a safe and structured way to handle different types of seeds.

Throws

if the initial value is negative.

Inheritors

Types

Link copied to clipboard
class Explicit(val value: Long) : Seed

Represents an explicit seed with a specific long value.

Link copied to clipboard
class Random : Seed

Represents a random seed generated using the system's random number generator.

Properties

Link copied to clipboard
val value: Long

The underlying long value used for the seed. Must be non-negative.

Functions

Link copied to clipboard
open operator override fun compareTo(other: Seed): Int

Compares this Seed object with another Seed object. Random seeds are considered equal to other Random seeds, while Explicit seeds are compared based on their values.

Link copied to clipboard
fun copy(seed: Long? = null): Seed

Creates a copy of the Seed object with an optional new value. If no value is provided, the current value is used.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open fun nextSeed(): Seed

Generates a new Seed object with an incremented value, if applicable. This is the default behavior for Explicit seeds, while Random seeds remain the same. Subclasses can override this method to provide different behavior.

Link copied to clipboard

Returns a kotlin.random.Random instance based on the value of this seed.

Link copied to clipboard
open override fun toString(): String

Returns a string representation of the Seed object. It indicates the type (Random or Explicit) and the underlying value.