pub struct AvlTree<P, T> { /* private fields */ }Expand description
An AVL tree of payloads by position, its nodes kept in a list.
A node can stand at a position without a payload, as music21’s
createNodeAtPosition leaves one.
Implementations§
Source§impl<P: PartialOrd + Clone, T> AvlTree<P, T>
impl<P: PartialOrd + Clone, T> AvlTree<P, T>
Sourcepub fn from_sorted(items: Vec<(P, T)>) -> Self
pub fn from_sorted(items: Vec<(P, T)>) -> Self
A balanced tree of items sorted by strictly rising position.
Sourcepub fn insert(&mut self, position: P, payload: T)
pub fn insert(&mut self, position: P, payload: T)
Puts a payload at a position, replacing what was there.
Sourcepub fn position_after(&self, position: &P) -> Option<&P>
pub fn position_after(&self, position: &P) -> Option<&P>
The first position after one given.
Sourcepub fn position_before(&self, position: &P) -> Option<&P>
pub fn position_before(&self, position: &P) -> Option<&P>
The last position before one given.
Sourcepub fn root_position(&self) -> Option<&P>
pub fn root_position(&self) -> Option<&P>
The root’s position.
Trait Implementations§
Source§impl<P: PartialOrd + Clone, T> AvlNodes for AvlTree<P, T>
impl<P: PartialOrd + Clone, T> AvlNodes for AvlTree<P, T>
Source§fn set_left(
&mut self,
node: &usize,
child: Option<usize>,
) -> Result<(), TreeError>
fn set_left( &mut self, node: &usize, child: Option<usize>, ) -> Result<(), TreeError>
Sets its left child.
Source§fn set_right(
&mut self,
node: &usize,
child: Option<usize>,
) -> Result<(), TreeError>
fn set_right( &mut self, node: &usize, child: Option<usize>, ) -> Result<(), TreeError>
Sets its right child.
Source§fn shape(&self, node: &usize) -> Result<Shape, TreeError>
fn shape(&self, node: &usize) -> Result<Shape, TreeError>
Its height and balance as last updated.
Source§fn set_shape(&mut self, node: &usize, shape: Shape) -> Result<(), TreeError>
fn set_shape(&mut self, node: &usize, shape: Shape) -> Result<(), TreeError>
Sets its height and balance.
Source§fn holds(
&self,
node: &usize,
compare: Compare,
position: &P,
) -> Result<bool, TreeError>
fn holds( &self, node: &usize, compare: Compare, position: &P, ) -> Result<bool, TreeError>
Whether
node.position <compare> position.Auto Trait Implementations§
impl<P, T> Forget for AvlTree<P, T>
impl<P, T> Freeze for AvlTree<P, T>
impl<P, T> Move for AvlTree<P, T>
impl<P, T> RefUnwindSafe for AvlTree<P, T>where
Vec<Slot<P, T>>: RefUnwindSafe,
impl<P, T> Send for AvlTree<P, T>
impl<P, T> Sync for AvlTree<P, T>
impl<P, T> Unpin for AvlTree<P, T>
impl<P, T> UnsafeUnpin for AvlTree<P, T>where
Vec<Slot<P, T>>: UnsafeUnpin,
impl<P, T> UnwindSafe for AvlTree<P, T>where
Vec<Slot<P, 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more