kpermute

FullIntPermutation

class FullIntPermutation(rng: Random = Random.Default, rounds: Int = 2, c1: Int = -2048144789, c2: Int = -1028477387) : IntPermutation(source)

Full 32-bit integer permutation over the entire signed Int domain.

Uses an invertible hash built from XOR, shifts, and odd multipliers with per-round keys. No tables are stored; encode and decode apply forward and inverse rounds respectively.

Parameters

rng

Source of randomness for generating round keys.

rounds

Number of mixing rounds; more rounds increase dispersion.

c1

First odd multiplicative constant used in the mixing steps.

c2

Second odd multiplicative constant used in the mixing steps.

Constructors

Link copied to clipboard
constructor(rng: Random = Random.Default, rounds: Int = 2, c1: Int = -2048144789, c2: Int = -1028477387)

Properties

Link copied to clipboard
open override val size: Int

Domain size of the permutation.

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

FullIntPermutation

constructor(rng: Random = Random.Default, rounds: Int = 2, c1: Int = -2048144789, c2: Int = -1028477387)(source)

Parameters

rng

Source of randomness for generating round keys.

rounds

Number of mixing rounds; more rounds increase dispersion.

c1

First odd multiplicative constant used in the mixing steps.

c2

Second odd multiplicative constant used in the mixing steps.

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)

Domain size of the permutation.

  • size >= 0: finite domain [0, size).

  • size == -1: full signed 32-bit domain.

toString

open override fun toString(): String(source)