kpermute

intPermutation

fun intPermutation(size: Int = Int.MAX_VALUE, rng: Random = Random.Default, rounds: Int = 0): IntPermutation(source)

Creates an IntPermutation for a contiguous integer domain.

The concrete implementation depends on size:

When rounds is 0, a size-dependent default is chosen to balance speed and dispersion. The permutation is reproducible for a given rng state.

Return

an IntPermutation with domain [0, size) or the full 32-bit space when size == -1.

Parameters

size

domain size. For non-negative values the domain is [0, size). Special values: -1 selects a full 32-bit permutation, other negative values select an unsigned-style domain.

rng

random source used to derive internal keys and parameters.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.


fun intPermutation(size: Int = Int.MAX_VALUE, seed: Long, rounds: Int = 0): IntPermutation(source)

Creates an IntPermutation using a seed-based Random instance.

This overload behaves like intPermutation with an explicit rng, but derives the random source from seed. For a fixed combination of [size, seed, rounds] the resulting permutation is deterministic.

Return

an IntPermutation with domain [0, size) or the full 32-bit space when size == -1.

Parameters

size

domain size; see intPermutation for semantics and special values.

seed

seed used to construct the underlying Random.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.

See also


fun intPermutation(range: IntRange, rng: Random = Random.Default, rounds: Int = 0): IntPermutation(source)

Creates an IntPermutation for values within the given inclusive range.

Internally this constructs a permutation over a domain of length range.last - range.first + 1, then wraps it so that IntPermutation.encode and IntPermutation.decode operate directly on values in range.

The same implementation selection rules and default rounds logic as intPermutation are used based on the range length.

Return

an IntPermutation whose domain is exactly range.

Parameters

range

inclusive range of values to permute.

rng

random source used to derive internal keys and parameters.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.

Throws

if range is empty or its length exceeds Int.MAX_VALUE.


fun intPermutation(range: IntRange, seed: Long, rounds: Int = 0): IntPermutation(source)

Creates an IntPermutation for the given inclusive range using a seed-based Random instance.

This overload behaves like intPermutation with an explicit rng, but derives the random source from seed.

Return

an IntPermutation whose domain is exactly range.

Parameters

range

inclusive range of values to permute.

seed

seed used to construct the underlying Random.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.

See also

longPermutation

fun longPermutation(size: Long = Long.MAX_VALUE, rng: Random = Random.Default, rounds: Int = 0): LongPermutation(source)

Creates a LongPermutation for a contiguous long domain.

The concrete implementation depends on size:

When rounds is 0, a size-dependent default is chosen to balance speed and dispersion. The permutation is reproducible for a given rng state.

Return

a LongPermutation with domain [0, size) or the full 64-bit space when size == -1L.

Parameters

size

domain size. For non-negative values the domain is [0, size). Special values: -1L selects a full 64-bit permutation, other negative values select an unsigned-style domain.

rng

random source used to derive internal keys and parameters.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.


fun longPermutation(size: Long = Long.MAX_VALUE, seed: Long, rounds: Int = 0): LongPermutation(source)

Creates a LongPermutation using a seed-based Random instance.

This overload behaves like longPermutation with an explicit rng, but derives the random source from seed. For a fixed combination of [size, seed, rounds] the resulting permutation is deterministic.

Return

a LongPermutation with domain [0, size) or the full 64-bit space when size == -1L.

Parameters

size

domain size; see longPermutation for semantics and special values.

seed

seed used to construct the underlying Random.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.

See also


fun longPermutation(range: LongRange, rng: Random = Random.Default, rounds: Int = 0): LongPermutation(source)

Creates a LongPermutation for values within the given inclusive range.

Internally this constructs a permutation over a domain of length range.last - range.first + 1, then wraps it so that IntPermutation.encode and IntPermutation.decode operate directly on values in range.

The same implementation selection rules and default rounds logic as longPermutation are used based on the range length.

Return

a LongPermutation whose domain is exactly range.

Parameters

range

inclusive range of values to permute.

rng

random source used to derive internal keys and parameters.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.

Throws

if range is empty or its length exceeds Long.MAX_VALUE.


Creates a LongPermutation for the given inclusive range using a seed-based Random instance.

This overload behaves like longPermutation with an explicit rng, but derives the random source from seed.

Return

a LongPermutation whose domain is exactly range.

Parameters

range

inclusive range of values to permute.

seed

seed used to construct the underlying Random.

rounds

number of mixing rounds; 0 selects a reasonable default per implementation.

See also