Expand description
A fast, index-based Red-Black Tree with no heap allocations.
§Features
- Flat storage: all nodes are stored in an
array, avoiding pointer indirection. - No allocations per node: avoids
Box,Rc, orArc. - No-std: works in embedded or bare-metal environments without relying on the Rust standard library.
- Preallocated with
MaybeUninit: memory for all nodes is allocated upfront, minimizing runtime overhead and ensuring safe initialization. - Fixed capacity: tree size is bounded at compile-time, making resource usage predictable.
expandedfeature (optional): enables tracking of subtree sizes for each node, allowing support forrank,select, andrange_countqueries.
§Simple example
use flat_rbtree::RedBlackTree;
let mut tree = RedBlackTree::<i32, &str, 10>::new();
tree.insert(10, "A");
tree.insert(20, "B");
tree.insert(5, "C");
tree.update(10, "Updated A");
if let Some(value) = tree.search(&10) {
println!("Key 10 has value: {}", value);
}
for (key, value) in tree.iter() {
println!("Key: {}, Value: {}", key, value);
}
assert_eq!(tree.remove(20), true);
if !tree.contains_key(&20) {
println!("Key 20 successfully removed");
}Structs§
- RedBlack
Tree - Index-based Red-Black Tree implementation
- RedBlack
Tree Iter - An iterator over the entries of a
RedBlackTree.