4 releases

Uses old Rust 2015

0.1.3 Oct 28, 2018
0.1.2 Mar 9, 2018
0.1.1 Mar 9, 2018
0.1.0 Mar 9, 2018

#9 in #slotmap

Download history 4/week @ 2022-02-21 1/week @ 2022-02-28 16/week @ 2022-03-14 12/week @ 2022-03-21 1/week @ 2022-04-04 25/week @ 2022-04-25 32/week @ 2022-05-02 4/week @ 2022-05-09

61 downloads per month

MIT license

15KB
290 lines

Deprecated: use slotmap.

Slot map: array storage with persistent indices

Vec<T>-like collection with stable indices. The underlying array's indices are re-used by incrementing a versioning tag in the index type.

The SlotMapIndex type consists of a u32 for storing the index into the underlying array, and a u32 for storing the version. Deleting and inserting more times than the maximum value of u32 will cause overflow and index conflict bugs.

Example

# use slotmapvec::*;
let mut map = SlotMapVec::new();

map.insert(123213);
let idx = map.insert(34234);
map.insert(654654);

map.remove(idx);
let idx2 = map.insert(999);
assert_eq!(map.get(idx), None);
assert_eq!(map.get(idx2), Some(&999));

lib.rs:

Slot map: array storage with persistent indices

Vec<T>-like collection with stable indices. The underlying array's indices are re-used by incrementing a versioning tag in the index type.

The SlotMapIndex type consists of a u32 for storing the index into the underlying array, and a u32 for storing the version. Deleting and inserting more times than the maximum value of u32 will cause overflow and index conflict bugs.

Examples

# use slotmapvec::*;
let mut map = SlotMapVec::new();

map.insert(123213);
let idx = map.insert(34234);
map.insert(654654);

map.remove(idx);
let idx2 = map.insert(999);

assert_eq!(map.get(idx), None);
assert_eq!(map.get(idx2), Some(&999));

No runtime deps