FingerTree

Build Status Coverage Status MIT License Crate API Docs

Finger trees is a functional representation of persistent sequences supporting access to the ends in amortized constant time, and concatenation and splitting in time logarithmic in the size of the smaller piece. It also has split operation defined in general form, which can be used to implement sequence, priority queue, search tree, priority search queue and more datastructures.

Links:

Notes:

Examples:

```rust use std::iter::FromIterator; use fingertrees::measure::Size; use fingertrees::monoid::Sum; use fingertrees::{FingerTree, Measured, RcRefs};

// construct Rc based finger tree with Size measure let ft: FingerTree = vec!["one", "two", "three", "four", "five"] .intoiter() .map(Size) .collect(); asserteq!(ft.measure(), Sum(5));

// split with predicate let (left, right) = ft.split(|measure| *measure > Sum(2)); asserteq!(left.measure(), Sum(2)); asserteq!(Vec::fromiter(&left), vec![Size("one"), Size("two")]); asserteq!(right.measure(), Sum(3)); asserteq!(Vec::fromiter(&right), vec![Size("three"), Size("four"), Size("five")]);

// concatinate assert_eq!(ft, left + right);

// push values asserteq!( ft.pushleft(Size("left")).pushright(Size("right")), vec!["left", "one", "two", "three", "four", "five", "right"] .intoiter() .map(Size) .collect(), ); ```