flattree
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.
Synopsis
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:
// what's the index of node 0? (depth:0, offset: 0)
index // => 0
// what's the index of node 1? (depth:0, offset: 0)
index // => 1
// parent of node 1
parent // => 3
// modify parent of node 2
let mut tree = vec!;
* = 4;
assert_eq!
LICENSE
Same As mafintosh/flat-tree, which is MIT right now.