sparse_map 0.1.2

A sparse map with stable generational keys.
Documentation
  • Coverage
  • 86.67%
    13 out of 15 items documented2 out of 15 items with examples
  • Size
  • Source code size: 27.24 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.51 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • voxell-tech/sparse_map
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nixonyh

Sparse Map

License Crates.io Downloads Docs CI Discord

A sparse map with stable generational keys. It is designed for scenarios with frequent insertions and removals.

The crate is no_std-friendly and uses generational indices to prevent use-after-free and slot reuse bugs.

Example

use sparse_map::SparseMap;

let mut map = SparseMap::new();
let k1 = map.insert(42);

let k2 = map.scope(&k1, |map, value| {
    let k = map.insert(*value);
    *value += 2;

    k
})
.expect("Key should exist.");

assert_eq!(map.get(&k1), Some(&44));
assert_eq!(map.get(&k2), Some(&42));

map.remove(&k1);
assert_eq!(map.get(&k1), None);

Join the community!

You can join us on the Voxell discord server.

License

sparse_map is dual-licensed under either:

This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.