Struct AVLTree

Source
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,

Source

pub fn new() -> Self

Creates a new, empty binary search tree.

Source

pub fn new_with_capacity(size: usize) -> Self

Creates a new, empty binary search tree with a given (growable) initial capacity.

Source

pub fn get_node<Q>(&self, key: &Q) -> Option<&T>
where Q: Ord + ?Sized, T: Borrow<Q>,

Gets a reference to the value of a key, if Some.

Source

pub fn get_root(&self) -> Option<&T>

Source

pub fn contains<Q>(&self, key: &Q) -> bool
where Q: Ord + ?Sized, T: Borrow<Q>,

Returns true if the key exists in the tree.

Source

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.

Source

pub fn remove<Q>(&mut self, key: &Q) -> Option<T>
where Q: Ord + ?Sized, T: Borrow<Q>,

Removes and returns an element from the AVL tree as an owned value.

Source

pub fn iter(&self) -> InOrderIter<'_, T>

Produces a “snapshot” iterator over immutable references to the tree in its current state.

Trait Implementations§

Source§

impl<T: Debug> Debug for AVLTree<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for AVLTree<T>
where T: Ord,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V