flat_rbtree
A fast, index-based Red-Black Tree with no heap allocations — ideal for systems where performance and memory layout matter.
Features
- Flat storage: all nodes are stored in a
array, avoiding pointer indirection. - No allocations per node: avoids
Box,Rc, orArc. - No-std: suitable for embedded environments.
- Preallocated with MaybeUninit: minimizes runtime overhead and ensures memory safety.
Usage
let mut tree = new;
tree.insert;
tree.update;
tree.search; // Some(&2)
tree.remove;
Benchmark: flat_rbtree vs rbtree (10,000 operations)
| Operation | flat_rbtree | rbtree |
|---|---|---|
| Insert | 1.14 ms | 1.34 ms |
| Remove | 2.12 ns | 354 ps |
| Search | 655 µs | 514 µs |
It’s worth noting that
rbtreeis a pointer-based implementation, which tends to be more performant than an index-based implementation.
📝 License
This project is open-source under the MIT License.