pub struct FingerTree<R, V>{ /* private fields */ }
Expand description
FingerTree implemenetation
FingerTree is parametrized by two type parpameters
Implementations§
Source§impl<R, V> FingerTree<R, V>
impl<R, V> FingerTree<R, V>
Sourcepub fn push_left(&self, value: V) -> Self
pub fn push_left(&self, value: V) -> Self
Creates new tree with value prepended to the left side of the tree
Amortized complexity: O(1)
Sourcepub fn push_right(&self, value: V) -> Self
pub fn push_right(&self, value: V) -> Self
Creates new tree with value prepended to the right side of the tree
Amortized complexity: O(1)
Sourcepub fn view_left(&self) -> Option<(V, Self)>
pub fn view_left(&self) -> Option<(V, Self)>
Destrutures tree into a tuple with first element of it containing first element from the left side of the tree, and second element contains tree with reset of the elements
Amortized complexity: O(1)
Sourcepub fn view_right(&self) -> Option<(V, Self)>
pub fn view_right(&self) -> Option<(V, Self)>
Destrutures tree into a tuple with first element of it containing first element from the right side of the tree, and second element contains tree with reset of the elements
Amortized complexity: O(1)
Sourcepub fn split<F>(&self, pred: F) -> (FingerTree<R, V>, FingerTree<R, V>)
pub fn split<F>(&self, pred: F) -> (FingerTree<R, V>, FingerTree<R, V>)
Destructures tree into two three, using provided predicate.
Predicate must be monotinic function accepting accumulated measure of elements
and changing its value from false
to true
. This function basically behave
as if we would iterate all elements from left to right, and accumlating measure
of all iterated elements, calling predicate on this accumulated value and once
its value flips from false
to true
we stop iteration and form two trees
from already iterated elements and the rest of the elements.
Complexity: O(ln(N))
Sourcepub fn split_left<F>(&self, pred: F) -> FingerTree<R, V>
pub fn split_left<F>(&self, pred: F) -> FingerTree<R, V>
partial logic from .split(...)
with only left part returned
Sourcepub fn split_right<F>(&self, pred: F) -> FingerTree<R, V>
pub fn split_right<F>(&self, pred: F) -> FingerTree<R, V>
partial logic from .split(...)
with only right part returned
Sourcepub fn find<F>(&self, pred: F) -> Option<&V>
pub fn find<F>(&self, pred: F) -> Option<&V>
Find element for which predicate function pred
flips from false
to true
Trait Implementations§
Source§impl<'a, 'b, R, V> Add<&'b FingerTree<R, V>> for &'a FingerTree<R, V>
impl<'a, 'b, R, V> Add<&'b FingerTree<R, V>> for &'a FingerTree<R, V>
Source§type Output = FingerTree<R, V>
type Output = FingerTree<R, V>
+
operator.