This create includes a series of helpers to map or traverse a binary tree on a list.
This crate is an almost line-by-line translation from mafintosh/flat-tree. I'm using it as an excuse to write some rust.
You can represent a binary tree in a simple flat list using the following structure
``` 3 1 5 0 2 4 6
```
and we can traverse the tree with this crate:
```rust // what's the index of node 0? (depth:0, offset: 0) index(0, 0) // => 0 // what's the index of node 1? (depth:0, offset: 0) index(1, 0) // => 1
// parent of node 1 parent(1) // => 3
// modify parent of node 2 let mut tree = vec![0,1,2]; *(tree.get_mut(parent(2)).unwrap()) = 4;
assert_eq!(tree.get(parent(2)).unwrap(), &4)
```
Same As mafintosh/flat-tree, which is MIT right now.