calcit_fingertrees

Struct FingerTree

Source
pub struct FingerTree<R, V>
where R: Refs<V>, V: Measured,
{ /* private fields */ }
Expand description

FingerTree implemenetation

FingerTree is parametrized by two type parpameters

  • R - type family trick which determines type of references used in implementation. This crate implementes ArcRefs which is based on Arc atomic reference counter, and RcRefs which is based on Rc.
  • V - value type which must be measurable and cheaply clonable.

Implementations§

Source§

impl<R, V> FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source

pub fn new() -> Self

Constructs a new, empty FingerTree

Complexity: O(1)

Source

pub fn is_empty(&self) -> bool

Returns true if finger tree is empty

Complexity: O(1)

Source

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)

Source

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)

Source

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)

Source

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)

Source

pub fn split<F>(&self, pred: F) -> (FingerTree<R, V>, FingerTree<R, V>)
where F: FnMut(&V::Measure) -> bool,

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

Source

pub fn split_left<F>(&self, pred: F) -> FingerTree<R, V>
where F: FnMut(&V::Measure) -> bool,

partial logic from .split(...) with only left part returned

Source

pub fn split_right<F>(&self, pred: F) -> FingerTree<R, V>
where F: FnMut(&V::Measure) -> bool,

partial logic from .split(...) with only right part returned

Source

pub fn find<F>(&self, pred: F) -> Option<&V>
where F: FnMut(&V::Measure) -> bool,

Find element for which predicate function pred flips from false to true

Source

pub fn concat(&self, other: &Self) -> Self

Construct new finger tree wich is concatination of self and other

Complexity: O(ln(N))

Source

pub fn iter(&self) -> Iter<R, V>

Double ended iterator visiting all elements of the tree from left to right

Trait Implementations§

Source§

impl<'a, 'b, R, V> Add<&'b FingerTree<R, V>> for &'a FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

type Output = FingerTree<R, V>

The resulting type after applying the + operator.
Source§

fn add(self, other: &'b FingerTree<R, V>) -> Self::Output

Performs the + operation. Read more
Source§

impl<R, V> Add for FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

type Output = FingerTree<R, V>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<R, V> Clone for FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<R, V> Debug for FingerTree<R, V>
where R: Refs<V>, V: Measured + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R, V> Default for FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<R, V> FromIterator<V> for FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

fn from_iter<I: IntoIterator<Item = V>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, R, V> IntoIterator for &'a FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

type Item = V

The type of the elements being iterated over.
Source§

type IntoIter = Iter<R, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<R, V> IntoIterator for FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

type Item = V

The type of the elements being iterated over.
Source§

type IntoIter = Iter<R, V>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<R, V> Measured for FingerTree<R, V>
where R: Refs<V>, V: Measured,

Source§

type Measure = <V as Measured>::Measure

Measure type
Source§

fn measure(&self) -> Self::Measure

Assocated measure with given value
Source§

impl<R, V> PartialEq for FingerTree<R, V>
where R: Refs<V>, V: Measured + PartialEq,

Source§

fn eq(&self, other: &FingerTree<R, V>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<R, V> Eq for FingerTree<R, V>
where R: Refs<V>, V: Measured + Eq,

Auto Trait Implementations§

§

impl<R, V> Freeze for FingerTree<R, V>
where <R as Refs<V>>::Tree: Freeze, <R as Refs<V>>::Node: Freeze,

§

impl<R, V> RefUnwindSafe for FingerTree<R, V>
where <R as Refs<V>>::Tree: RefUnwindSafe, <R as Refs<V>>::Node: RefUnwindSafe,

§

impl<R, V> Send for FingerTree<R, V>
where <R as Refs<V>>::Tree: Send, <R as Refs<V>>::Node: Send,

§

impl<R, V> Sync for FingerTree<R, V>
where <R as Refs<V>>::Tree: Sync, <R as Refs<V>>::Node: Sync,

§

impl<R, V> Unpin for FingerTree<R, V>
where <R as Refs<V>>::Tree: Unpin, <R as Refs<V>>::Node: Unpin,

§

impl<R, V> UnwindSafe for FingerTree<R, V>
where <R as Refs<V>>::Tree: UnwindSafe, <R as Refs<V>>::Node: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.