whistlinoak

Crates.iowhistlinoak
lib.rswhistlinoak
version0.2.1
sourcesrc
created_at2022-08-05 23:16:20.640183
updated_at2022-08-17 18:50:16.053384
descriptionAnnotated even-arity trees backed by mmaps
homepage
repositoryhttps://github.com/ureeves/whistlinoak
max_upload_size
id639607
size49,917
Eduardo Leegwater Simões (ureeves)

documentation

README

Whistlin'Oak

Repository Build Status Documentation

Annotated even-arity trees backed by arbitrary memories.

Usage

whistlinoak = "0.2"

Example

use whistlinoak::{Annotation, Tree};

struct Cardinality(usize);

impl<T> Annotation<T> for Cardinality {
    fn compute(leaf: &T) -> Self {
        Cardinality(1)
    }

    fn combine<'a>(annotations: impl Iterator<Item=&'a Self>) -> Self
    where
        Self: 'a
    {
        Self(annotations.fold(0, |curr, c| curr + c.0))
    }
}

let mut tree = Tree::<usize, Cardinality>::new();

let n_leaves = 1000;

for i in 0..n_leaves {
    tree.push(i).unwrap();
}

assert_eq!(tree.len(), n_leaves);
assert_eq!(tree.root().0, n_leaves);
Commit count: 15

cargo fmt