orlp/slotmap
orlp/slotmap has 1,369 GitHub stars and 96 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 06:28 UTC. Last push 2026-09-04.
Slotmap data structure for Rust
Measured star growth
- in 24h
- 0
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalslotmap
A Rust library providing three containers with persistent unique keys to access
stored values, SlotMap, HopSlotMap and DenseSlotMap. Upon insertion a key
is returned that can be used to later access or remove the values. Insertion,
deletion and access all take O(1) time with low overhead. Great for storing
collections of objects that need stable, safe references but have no clear
ownership otherwise, such as game entities or graph nodes. Two secondary maps,
SecondaryMap and SparseSecondaryMap are also provided that allow you to map
further objects to the keys created by one of the slot maps. Please refer to
the documentation for more information.
The minimum required stable Rust version for slotmap is 1.58. To start using
slotmap add the following to your Cargo.toml:
[dependencies]
slotmap = "1.0"
Example
A short example:
use slotmap::{SlotMap, SecondaryMap};
let mut sm = SlotMap::new();
let foo = sm.insert("foo"); // Key generated on insert.
let bar = sm.insert("bar");
assert_eq!(sm[foo], "foo");
assert_eq!(sm[bar], "bar");
sm.remove(bar);
let reuse = sm.insert("reuse"); // Space from bar reused.
assert_eq!(sm.contains_key(bar), false); // After deletion a key stays invalid.
let mut sec = SecondaryMap::new();
sec.insert(foo, "noun"); // We provide the key for secondary maps.
sec.insert(reuse, "verb");
for (key, val) in sm {
println!("{} is a {}", val, sec[key]);
}
License
slotmap is released under the Zlib license, a permissive license. It is
OSI and FSF approved and GPL compatible.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,847 starspublic-apis/public-apis
A collective list of free APIs
497,093 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
441,612 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,159 stars