pub struct AVLTree<T> {
pub arena: Vec<Option<AVLNode<T>>>,
/* private fields */
}Expand description
§About
See the module-level documentation for more information.
Fields§
§arena: Vec<Option<AVLNode<T>>>Implementations§
Source§impl<T> AVLTree<T>where
T: Ord,
impl<T> AVLTree<T>where
T: Ord,
Sourcepub fn new_with_capacity(size: usize) -> Self
pub fn new_with_capacity(size: usize) -> Self
Creates a new, empty binary search tree with a given (growable) initial capacity.
Sourcepub fn get_node<Q>(&self, key: &Q) -> Option<&T>
pub fn get_node<Q>(&self, key: &Q) -> Option<&T>
Gets a reference to the value of a key, if Some.
pub fn get_root(&self) -> Option<&T>
Sourcepub fn insert(&mut self, key: T)where
T: Ord,
pub fn insert(&mut self, key: T)where
T: Ord,
Inserts the given key into the tree maintaining an AVL structure.
NOTE: Does not handle duplicate keys by convention, but may overwrite values for arbitrarily complex T with custom Ordering.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<T>
pub fn remove<Q>(&mut self, key: &Q) -> Option<T>
Removes and returns an element from the AVL tree as an owned value.
Sourcepub fn iter(&self) -> InOrderIter<'_, T> ⓘ
pub fn iter(&self) -> InOrderIter<'_, T> ⓘ
Produces a “snapshot” iterator over immutable references to the tree in its current state.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for AVLTree<T>
impl<T> RefUnwindSafe for AVLTree<T>where
T: RefUnwindSafe,
impl<T> Send for AVLTree<T>where
T: Send,
impl<T> Sync for AVLTree<T>where
T: Sync,
impl<T> Unpin for AVLTree<T>where
T: Unpin,
impl<T> UnwindSafe for AVLTree<T>where
T: 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