slotmap-0.2.0 has been yanked.
slotmap
A Rust library providing two containers with persistent unique keys to access
stored values, SlotMap
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. Please refer to the
the documentation for more information.
To start using slotmap
add the following to your Cargo.toml
:
[]
= "0.2"
Example
A short example:
use SlotMap;
let mut sm = new;
let foo = sm.insert; // Key generated on insert.
let bar = sm.insert;
assert_eq!;
assert_eq!;
sm.remove;
let reused = sm.insert; // Space from bar reused.
assert_eq!; // After deletion a key stays invalid.
License
slotmap
is released under the Zlib license, a permissive license. It is
OSI and FSF approved and GPL compatible.