pub struct SumAugmentation;Expand description
Augmentation that tracks the sum of all values in each subtree.
Useful for range-sum queries: after locating the range boundaries, access the subtree statistics to get aggregate sums.
The value type V must implement core::ops::Add, Copy, and provide a
zero element via Default.
§Examples
use augmented_rbtree::{AugmentedRBTree, augmentations::SumAugmentation};
let mut tree = AugmentedRBTree::<i32, i64, SumAugmentation>::new();
tree.insert(1, 10);
tree.insert(2, 20);
tree.insert(3, 30);
// Root stats holds the sum of all values
assert_eq!(tree.root_stats(), Some(&60));Trait Implementations§
Source§impl<K, V> Augment<K, V> for SumAugmentation
impl<K, V> Augment<K, V> for SumAugmentation
Auto Trait Implementations§
impl Freeze for SumAugmentation
impl RefUnwindSafe for SumAugmentation
impl Send for SumAugmentation
impl Sync for SumAugmentation
impl Unpin for SumAugmentation
impl UnsafeUnpin for SumAugmentation
impl UnwindSafe for SumAugmentation
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