AVLTree

Struct AVLTree 

Source
pub struct AVLTree<T: Ord> { /* private fields */ }
Expand description

A set based on an AVL Tree.

An AVL Tree is a self-balancing binary search tree. It tracks the height of each node and performs internal rotations to maintain a height difference of at most 1 between each sibling pair.

Implementations§

Source§

impl<T: Ord> AVLTree<T>

Source

pub fn new() -> AVLTree<T>

Creates an empty AVLTree.

Source

pub fn contains(&self, value: &T) -> bool

Returns true if the tree contains a value.

Source

pub fn insert(&mut self, value: T) -> bool

Adds a value to the tree.

Returns true if the tree did not yet contain the value.

Source

pub fn remove(&mut self, value: &T) -> bool

Removes a value from the tree.

Returns true if the tree contained the value.

Source

pub fn len(&self) -> usize

Returns the number of values in the tree.

Source

pub fn is_empty(&self) -> bool

Returns true if the tree contains no values.

Source

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

Returns an iterator that visits the values in the tree in ascending order.

Trait Implementations§

Source§

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

Source§

fn default() -> Self

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

impl<T: Ord> FromIterator<T> for AVLTree<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. 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>

§

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