kpermute

BoundedLongPermutation

class BoundedLongPermutation(val size: Long, rng: Random = Random.Default, rounds: Int = 3, const: ULong) : LongPermutation(source)

Permutation over [0, size) that mixes within the enclosing power-of-two block and cycle-walks until the output lands in range. size is read as unsigned, so -1 means 2^64 - 1 values. const must be odd.

Constructors

BoundedLongPermutation

constructor(size: Long, rng: Random = Random.Default, rounds: Int = 3, const: ULong)(source)

Properties

size

open override val size: Long(source)

Domain size, read as unsigned; -1L means all 64-bit values.

Functions

decode

open override fun decode(encoded: Long): Long(source)

Inverse of encode; throws if encoded is outside the domain.

decodeUnchecked

open override fun decodeUnchecked(encoded: Long): Long(source)

decode without range checks. Out-of-domain input is unspecified and may not terminate.

encode

open override fun encode(value: Long): Long(source)

Maps value to its permuted position; throws if value is outside the domain.

encodeUnchecked

open override fun encodeUnchecked(value: Long): Long(source)

encode without range checks. Out-of-domain input is unspecified and may not terminate.

iterator

open override fun iterator(offset: Long): LongIterator(source)

Iterates encode(i) for unsigned indices i from offset, which must be in 0..size.

toString

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

Returns a view of this permutation shifted onto range, which must hold exactly LongPermutation.size values. On an existing range view, replaces its range.