pub struct SumTree<T: Item>(/* private fields */);Expand description
A B+ tree in which each leaf node contains Items of type T and a Summarys 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 items<'a>(&'a self, cx: <T::Summary as Summary>::Context<'a>) -> Vec<T>
pub fn iter(&self) -> Iter<'_, T> ⓘ
Sourcepub fn find_exact<'a, 'slf, D, Target>(
&'slf self,
cx: <T::Summary as Summary>::Context<'a>,
target: &Target,
bias: Bias,
) -> (D, D, Option<&'slf T>)
pub fn find_exact<'a, 'slf, D, Target>( &'slf self, cx: <T::Summary as Summary>::Context<'a>, target: &Target, bias: Bias, ) -> (D, D, Option<&'slf T>)
A more efficient version of Cursor::new() + Cursor::seek() + Cursor::item().
Only returns the item that exactly has the target match.
Sourcepub fn find<'a, 'slf, D, Target>(
&'slf self,
cx: <T::Summary as Summary>::Context<'a>,
target: &Target,
bias: Bias,
) -> (D, D, Option<&'slf T>)
pub fn find<'a, 'slf, D, Target>( &'slf self, cx: <T::Summary as Summary>::Context<'a>, target: &Target, bias: Bias, ) -> (D, D, Option<&'slf T>)
A more efficient version of Cursor::new() + Cursor::seek() + Cursor::item()
Sourcepub fn find_with_prev<'a, 'slf, D, Target>(
&'slf self,
cx: <T::Summary as Summary>::Context<'a>,
target: &Target,
bias: Bias,
) -> (D, D, Option<(Option<&'slf T>, &'slf T)>)
pub fn find_with_prev<'a, 'slf, D, Target>( &'slf self, cx: <T::Summary as Summary>::Context<'a>, target: &Target, bias: Bias, ) -> (D, D, Option<(Option<&'slf T>, &'slf T)>)
A more efficient version of Cursor::new() + Cursor::seek() + Cursor::item()
pub fn cursor<'a, 'b, D>( &'a self, cx: <T::Summary as Summary>::Context<'b>, ) -> Cursor<'a, 'b, T, D> ⓘ
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.