pub struct SubtreeSize<S = usize>(/* private fields */);Expand description
Augmentation that tracks the number of nodes in each subtree.
This enables O(log n) rank queries (find the k-th smallest element) and select operations when combined with custom traversal.
§Examples
use augmented_rbtree::{AugmentedRBTree, augmentations::SubtreeSize};
let mut tree = AugmentedRBTree::<i32, &str, SubtreeSize>::new();
tree.insert(3, "c");
tree.insert(1, "a");
tree.insert(2, "b");
assert_eq!(tree.root_stats(), Some(&3));
assert_eq!(tree.len(), 3);Trait Implementations§
Source§impl<K, V, S> Augment<K, V> for SubtreeSize<S>
impl<K, V, S> Augment<K, V> for SubtreeSize<S>
Source§impl<S: Debug> Debug for SubtreeSize<S>
impl<S: Debug> Debug for SubtreeSize<S>
Source§impl<S: Default> Default for SubtreeSize<S>
impl<S: Default> Default for SubtreeSize<S>
Source§fn default() -> SubtreeSize<S>
fn default() -> SubtreeSize<S>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<S> Freeze for SubtreeSize<S>
impl<S> RefUnwindSafe for SubtreeSize<S>where
S: RefUnwindSafe,
impl<S> Send for SubtreeSize<S>where
S: Send,
impl<S> Sync for SubtreeSize<S>where
S: Sync,
impl<S> Unpin for SubtreeSize<S>where
S: Unpin,
impl<S> UnsafeUnpin for SubtreeSize<S>
impl<S> UnwindSafe for SubtreeSize<S>where
S: UnwindSafe,
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