Struct AVLTree

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

Arena based memory tree structure

Trait Implementations§

Source§

impl<T> BaseTree<T> for AVLTree<T>
where T: PartialOrd + PartialEq + Debug,

Source§

fn get(&self, val: usize) -> &Self::MNode

In order to return a reference to a value of a vector contained within a refcell, a raw pointer is used. The unsafe code could be avoided by replacing each call to self.get(n) with &self.data.borrow()[n] and each call to self.get_mut(n) with &mut self.data.borrow()[n]. This allows us to do the same thing with less keystrokes. It does make the program not thread-safe, but a this data structure is a pretty terrible choice for a multi-threaded data structure anyways, since re-balancing can require that most of the tree be locked to one thread during an insertion or deletion

Source§

type MNode = AVLNode<T>

Source§

fn get_mut(&self, val: usize) -> &mut Self::MNode

Source§

fn get_root(&self) -> Option<usize>

Source§

fn set_root(&mut self, new_root: Option<usize>)

Source§

fn crement_size(&mut self, amount: isize)

Source§

fn attach_child(&self, p: usize, c: usize, side: Side)

Source§

fn rebalance_ins(&mut self, n: usize)

Source§

fn rebalance_del(&mut self, n: usize, _child: usize)

Source§

fn delete_replace(&mut self, n: usize) -> usize

Source§

fn replace_node(&mut self, _to_delete: usize, _to_attach: Option<usize>)

Source§

fn get_size(&self) -> usize

Source§

fn create_node(&mut self, val: T) -> usize

Source§

fn delete_node(&mut self, index: usize)

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> Tree<T> for AVLTree<T>
where T: PartialOrd + PartialEq + Debug,

Source§

fn new() -> Self

Source§

fn is_empty(&self) -> bool

Source§

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

Source§

fn insert(&mut self, val: T)

Source§

fn delete(&mut self, val: T) -> bool

Source§

fn rotate(&mut self, side: Side, n: usize)

Source§

fn find(&self, val: &T) -> usize

Source§

fn get_height(&self) -> usize

Source§

fn get_leaf_count(&self) -> usize

Source§

fn to_string(&self) -> String

Source§

fn to_pretty_string(&self) -> String

Auto Trait Implementations§

§

impl<T> Freeze for AVLTree<T>

§

impl<T> !RefUnwindSafe for AVLTree<T>

§

impl<T> !Send for AVLTree<T>

§

impl<T> !Sync for AVLTree<T>

§

impl<T> Unpin for AVLTree<T>

§

impl<T> !UnwindSafe for AVLTree<T>

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.