[][src]Crate genmap



A collection of T's referred to by Handle's. When you add an object to the GenMap it will return a Handle, and you can look that item up by that Handle. You can also remove the item, which makes any old Handle's to it become invalid and attempting to get it will return None.


A Rust crate for a generational map, handle map, whatever you want to call it. Whatever it is, this is a random-access data structure that stores an unordered bag of items and gives you a handle for each specific item you insert. Looking things up by handle is O(1) -- the backing storage is just a Vec -- and items can be removed as well, which is also O(1). Handles are small (two usize's) and easy to copy, similar to a slice. The trick is that there is a generation number stored with each item, so that a "dangling" handle that refers to an item that has been removed is invalid. Unlike array indices, if you remove an item from the array and a new one gets put in its place, the old stale handle does not refer to the new one and trying to use it will fail at runtime.


Iterator over keys in a GenMap.