| Crates.io | flat_rbtree |
| lib.rs | flat_rbtree |
| version | 0.2.3 |
| created_at | 2025-06-29 13:55:53.285085+00 |
| updated_at | 2025-07-05 16:46:33.79951+00 |
| description | A flat, index-based Red-Black Tree with no heap allocations. Ideal for performance-critical or memory-constrained environments. |
| homepage | |
| repository | https://github.com/matheus-git/flat_rbtree |
| max_upload_size | |
| id | 1730765 |
| size | 66,986 |
A fast, index-based Red-Black Tree with no heap allocations — ideal for systems where performance and memory layout matter.
See Documentation
array, avoiding pointer indirection.Box, Rc, or Arc.expanded feature (optional): enables tracking of subtree sizes for each node,
allowing support for rank, select, and range_count queries.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);
}
tree.remove(20);
if !tree.contains_key(&20) {
println!("Key 20 successfully removed");
}
Since all operations are at most O(log n), this benchmark is just to give an idea of the performance compared to a pointer-based implementation.
| Operation | flat_rbtree | rbtree |
|---|---|---|
| Insert | 1.14 ms | 1.34 ms |
| Remove | 2.12 ns | 354 ps |
| Search | 655 µs | 514 µs |
This project is open-source under the MIT License.