pub struct SumTree<T: Item>(/* private fields */);
Expand description
A B+ tree in which each leaf node contains Item
s of type T
and a Summary
s for each Item
.
Each internal node contains a Summary
of the items in its subtree.
The maximum number of items per node is TREE_BASE * 2
.
Any Dimension
supported by the Summary
type can be used to seek to a specific location in the tree.
Implementations§
Source§impl<T: Item> SumTree<T>
impl<T: Item> SumTree<T>
pub fn new(cx: <T::Summary as Summary>::Context<'_>) -> Self
Sourcepub fn from_summary(summary: T::Summary) -> Self
pub fn from_summary(summary: T::Summary) -> Self
Useful in cases where the item type has a non-trivial context type, but the zero value of the summary type doesn’t depend on that context.
pub fn from_item(item: T, cx: <T::Summary as Summary>::Context<'_>) -> Self
pub fn from_iter<I: IntoIterator<Item = T>>( iter: I, cx: <T::Summary as Summary>::Context<'_>, ) -> Self
pub fn from_par_iter<I, Iter>( iter: I, cx: <T::Summary as Summary>::Context<'_>, ) -> Self
pub fn items<'a>(&'a self, cx: <T::Summary as Summary>::Context<'a>) -> Vec<T>
pub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn cursor<'a, 'b, S>( &'a self, cx: <T::Summary as Summary>::Context<'b>, ) -> Cursor<'a, 'b, T, S> ⓘ
Sourcepub fn filter<'a, 'b, F, U>(
&'a self,
cx: <T::Summary as Summary>::Context<'b>,
filter_node: F,
) -> FilterCursor<'a, 'b, F, T, U> ⓘ
pub fn filter<'a, 'b, F, U>( &'a self, cx: <T::Summary as Summary>::Context<'b>, filter_node: F, ) -> FilterCursor<'a, 'b, F, T, U> ⓘ
Note: If the summary type requires a non ()
context, then the filter cursor
that is returned cannot be used with Rust’s iterators.
pub fn first(&self) -> Option<&T>
pub fn last(&self) -> Option<&T>
pub fn update_last( &mut self, f: impl FnOnce(&mut T), cx: <T::Summary as Summary>::Context<'_>, )
pub fn extent<'a, D: Dimension<'a, T::Summary>>( &'a self, cx: <T::Summary as Summary>::Context<'_>, ) -> D
pub fn summary(&self) -> &T::Summary
pub fn is_empty(&self) -> bool
pub fn extend<I>(&mut self, iter: I, cx: <T::Summary as Summary>::Context<'_>)where
I: IntoIterator<Item = T>,
pub fn par_extend<I, Iter>( &mut self, iter: I, cx: <T::Summary as Summary>::Context<'_>, )
pub fn push(&mut self, item: T, cx: <T::Summary as Summary>::Context<'_>)
pub fn append(&mut self, other: Self, cx: <T::Summary as Summary>::Context<'_>)
Source§impl<T: KeyedItem> SumTree<T>
impl<T: KeyedItem> SumTree<T>
pub fn insert_or_replace<'a, 'b>( &'a mut self, item: T, cx: <T::Summary as Summary>::Context<'b>, ) -> Option<T>
pub fn remove( &mut self, key: &T::Key, cx: <T::Summary as Summary>::Context<'_>, ) -> Option<T>
pub fn edit( &mut self, edits: Vec<Edit<T>>, cx: <T::Summary as Summary>::Context<'_>, ) -> Vec<T>
pub fn get<'a>( &'a self, key: &T::Key, cx: <T::Summary as Summary>::Context<'a>, ) -> Option<&'a T>
Trait Implementations§
impl<T: Item + Eq> Eq for SumTree<T>
Auto Trait Implementations§
impl<T> Freeze for SumTree<T>
impl<T> RefUnwindSafe for SumTree<T>
impl<T> Send for SumTree<T>
impl<T> Sync for SumTree<T>
impl<T> Unpin for SumTree<T>
impl<T> UnwindSafe for SumTree<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more