kpermute

ArrayLongPermutation

Finite in-memory long permutation backed by a LongArray lookup table.

Builds a random bijection over [0, size) by shuffling the identity mapping and precomputing the inverse. Encode and decode are O(1) array lookups.

Parameters

rng

Random generator used to create the shuffled mapping.

Constructors

ArrayLongPermutation

constructor(size: Long, rng: Random)(source)

Parameters

rng

Random generator used to create the shuffled mapping.

Properties

size

open override val size: Long(source)

Functions

decodeUnchecked

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

Decodes a previously encoded value without range checks.

encodeUnchecked

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

Encodes a value without range checks.

iterator

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

Returns an iterator over encode(i) for indices in [offset, size).

For finite domains, offset is an index in 0..size. For full-domain implementations, semantics are defined by the implementation.

toString

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

Decodes a previously encoded long back to its original value.

Link copied to clipboard
open fun encode(value: Long): Long

Encodes a long in the permutation domain into its permuted value.

Link copied to clipboard

Returns a view of this permutation that operates on range instead of [0, size). Only valid for finite domains where range.count() == size.