| Crates.io | tree-index |
| lib.rs | tree-index |
| version | 0.6.1 |
| created_at | 2018-04-09 14:14:33.693432+00 |
| updated_at | 2020-07-09 21:27:15.632717+00 |
| description | Index a flat-tree |
| homepage | |
| repository | https://github.com/datrs/tree-index |
| max_upload_size | |
| id | 59725 |
| size | 49,264 |
Stateful tree index. Or well, stateful flat-tree. It's what happens when you combine a flat-tree with a sparse-bitfield - which ends up being pretty cool!
Adapted from mafintosh/hypercore/lib/tree-index.js.
extern crate sparse_bitfield as bitfield;
extern crate tree_index;
use tree_index::TreeIndex;
use self::bitfield::{Bitfield, Change};
let bitfield = Bitfield::new(1024);
let mut tree = TreeIndex::new(bitfield);
assert_eq!(tree.set(0), Change::Changed);
assert_eq!(tree.set(0), Change::Unchanged);
assert_eq!(tree.get(0), true);
assert_eq!(tree.get(1), false);
$ cargo add tree-index
MIT OR Apache-2.0