kpermute

HalfIntPermutation

class HalfIntPermutation(val size: Int = Int.MAX_VALUE, rng: Random = Random.Default, rounds: Int = 3, const: Int = -1640531535) : IntPermutation(source)

Finite integer permutation using cycle-walking over a 2^k-sized block.

Embeds the domain [0, size) in a power-of-two block and applies reversible affine steps plus XOR-shift mixing. Outputs outside [0, size) are rejected and walked until they fall back inside the domain.

Parameters

rng

Random generator used to derive per-round keys.

rounds

Number of mixing rounds; higher values increase dispersion.

const

Odd multiplicative constant used in each affine step.

Constructors

Link copied to clipboard
constructor(size: Int = Int.MAX_VALUE, rng: Random = Random.Default, rounds: Int = 3, const: Int = -1640531535)

Properties

Link copied to clipboard
open override val size: Int

Size of the permutation domain; valid inputs are [0, size).

Functions

Link copied to clipboard
open fun decode(encoded: Int): Int

Decodes a previously encoded integer back to its original value.

Link copied to clipboard
open override fun decodeUnchecked(encoded: Int): Int

Decodes a previously encoded value without range checks.

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

Encodes an integer in the permutation domain into its permuted value.

Link copied to clipboard
open override fun encodeUnchecked(value: Int): Int

Encodes a value without range checks.

Link copied to clipboard
open override fun iterator(offset: Int): IntIterator

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

open operator override fun iterator(): IntIterator

Returns an iterator over encode(i) for all i in [0, size) for finite domains, or over the full 32-bit space when size == -1.

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.

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

HalfIntPermutation

constructor(size: Int = Int.MAX_VALUE, rng: Random = Random.Default, rounds: Int = 3, const: Int = -1640531535)(source)

Parameters

rng

Random generator used to derive per-round keys.

rounds

Number of mixing rounds; higher values increase dispersion.

const

Odd multiplicative constant used in each affine step.

decodeUnchecked

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

Decodes a previously encoded value without range checks.

encodeUnchecked

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

Encodes a value without range checks.

iterator

open override fun iterator(offset: Int): IntIterator(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.

size

open override val size: Int(source)

toString

open override fun toString(): String(source)