Documentation
¶
Overview ¶
Package perm provides a generator object which can be used to iterate through a permutation of a given range in constant space.
The current implementation uses a Feistel network, with blake2b as the round function. Note that since the entropy seeding the round function is typically far smaller than the full permutation space, the generator cannot enumerate the full space in such cases. For example, even a 128-bit key can only enumerate the permutation space of 34 elements, since 2^128 < 35!. This is a known limitation of Feistel networks.
For small n, it may be more efficient to enumerate [0,n) and permute the values in-place using the well-known Fisher-Yates algorithm (this is what math/rand.Perm uses). For convenience, such a function is provided in this package as well.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FisherYates ¶
FisherYates returns a pseudorandom permutation of the integers [0,n).
func NewGenerator ¶
func NewGenerator(numElems, seed uint32) *feistelGenerator
NewGenerator returns a new Feistel network-based permutation generator.
Types ¶
This section is empty.