gen_map
A customizable generational map that returns a Key upon inserting a value. The key can be used to later access or remove the value, and removing a value bumps its slot's generation, so the old key no longer matches.
The operations for inserting, removing and accessing a value are all O(1).
[]
= "0.1"
Example
use GenMap;
let mut map = new;
let a = map.insert;
let b = map.insert;
assert_eq!;
assert_eq!;
assert_eq!;
assert!; // A removed key stays invalid forever.
let c = map.insert; // This takes the slot `a` had, but under a new key.
assert_ne!;
for in &map
Configuring the key
A Config picks the index and generation integers and what happens when a
slot's generation overflows. The default uses a u32 index and a u32
generation, and a slot whose generation overflows is retired, so no stale key
can ever match a new value.
use ;
;
let mut map = new_with_config;
let key = map.insert;
assert_eq!;
Option<Key> is the same size as Key.
License
gen_map is released under the MIT license.