LongPermutation
Reversible permutation over a 64-bit integer domain.
A LongPermutation defines a bijection on either:
a finite domain
[0, size)whensize >= 0L, orthe full signed 64-bit space when
size == -1L.
Implementations are deterministic: the same instance always maps the same input to the same output, and decode is the exact inverse of encode. They are suitable for repeatable shuffling, masking, and index remapping without full lookup tables.
Security note: These permutations are not cryptographic. They are not PRPs and are not intended to resist adversarial inversion or analysis.
Contract:
For finite domains (
size >= 0L), valid inputs to encode and decode are in[0, size). Out-of-range values trigger IllegalArgumentException.encodeUnchecked and decodeUnchecked skip range checks and must only be called with valid domain values when
size >= 0L.iterator yields
encode(i)for all validiin index order.
Use longPermutation to construct concrete implementations.
Inheritors
Functions
Decodes a previously encoded value without range checks.
Encodes a value without range checks.
Returns an iterator over encode(i) for all i in [0, size) for finite domains, or over the full 64-bit space when size == -1L.
Returns an iterator over encode(i) for indices in [offset, size).
Returns a view of this permutation that operates on range instead of [0, size). Only valid for finite domains where range.count() == size.
decodeUnchecked
Decodes a previously encoded value without range checks.
decode
encodeUnchecked
Encodes a value without range checks.
encode
iterator
Returns an iterator over encode(i) for all i in [0, size) for finite domains, or over the full 64-bit space when size == -1L.
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.