Crate patricia_tree
source ·Expand description
Memory-efficient data structures based on patricia tree (a.k.a, radix tree).
A common prefixes of the keys in a patricia tree are represented by a shared path.
So if the prefixes of the key set is highly redundant,
the memory usage of the resulting patricia tree will be drastically less than
more generic data structures (e.g., BTreeMap
).
See Radix tree for more details.
Examples
use patricia_tree::PatriciaMap;
let mut map = PatriciaMap::new();
map.insert("foo", 1);
map.insert("bar", 2);
map.insert("baz", 3);
assert_eq!(map.len(), 3);
assert_eq!(map.get("foo"), Some(&1));
assert_eq!(map.get("bar"), Some(&2));
assert_eq!(map.get("baz"), Some(&3));
Re-exports
pub use map::GenericPatriciaMap;
pub use map::PatriciaMap;
pub use map::StringPatriciaMap;
pub use set::GenericPatriciaSet;
pub use set::PatriciaSet;
pub use set::StringPatriciaSet;
Modules
- A map based on a patricia tree.
- A set based on a patricia tree.
Traits
- Borrowed type of
Bytes
. - This trait represents a bytes type that can be used as the key type of patricia trees.