8 releases (5 breaking)

Uses old Rust 2015

0.6.1 Jul 9, 2020
0.6.0 Mar 3, 2020
0.5.0 Oct 18, 2018
0.4.1 Sep 3, 2018
0.1.0 Apr 9, 2018

#1340 in Data structures

MIT/Apache

16KB
248 lines

tree-index

crates.io version build status downloads docs.rs docs

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.

Usage

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);

Installation

$ cargo add tree-index

License

MIT OR Apache-2.0

Dependencies

~55KB