https://github.com/afnanenayet/hashed-permutation
An implementation of Kensler's hashed permutation algorithm
https://github.com/afnanenayet/hashed-permutation
hash hashed permutation permute shuffle
Last synced: 5 months ago
JSON representation
An implementation of Kensler's hashed permutation algorithm
- Host: GitHub
- URL: https://github.com/afnanenayet/hashed-permutation
- Owner: afnanenayet
- License: mit
- Created: 2019-09-09T03:53:39.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-01-31T17:57:16.000Z (9 months ago)
- Last Synced: 2025-04-26T07:52:59.907Z (6 months ago)
- Topics: hash, hashed, permutation, permute, shuffle
- Language: Rust
- Size: 71.3 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 7
-
Metadata Files:
- Readme: docs/README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# hashed-permutation
[](https://github.com/afnanenayet/hashed-permutation/actions/workflows/CI.yml)
[](https://crates.io/crates/hashed-permutation)
[](https://docs.rs/hashed-permutation)
## Synopsis
This is an implementation of Andrew Kensler's hashed permutation, which allows
you to take an array of the elements [0 ... n) and shuffle it with no memory
overhead and very little computational overhead. This works by using a clever
hash function to effectively permute all of the elements in the array.Basically, you get a nearly free method to shuffle a bunch of numbers that
doesn't require you to allocate a vector of size `n`, letting you sample the
set without replacement.You can find the paper here: https://graphics.pixar.com/library/MultiJitteredSampling/paper.pdf.
I have a little writeup of how the algorithm works [here](https://afnan.io/posts/2019-04-05-explaining-the-hashed-permutation),
and [Timothy Hobbs](https://github.com/timthelion) made a nice writeup explaining how to use the library itself
[here](https://timothy.hobbs.cz/rust-play/hashed-permutation.html).