Skip to main content

AvlNodes

Trait AvlNodes 

Source
pub trait AvlNodes {
    type Node: Clone;
    type Position;
    type Error: From<TreeError>;

    // Required methods
    fn left(&self, node: &Self::Node) -> Result<Option<Self::Node>, Self::Error>;
    fn right(
        &self,
        node: &Self::Node,
    ) -> Result<Option<Self::Node>, Self::Error>;
    fn set_left(
        &mut self,
        node: &Self::Node,
        child: Option<Self::Node>,
    ) -> Result<(), Self::Error>;
    fn set_right(
        &mut self,
        node: &Self::Node,
        child: Option<Self::Node>,
    ) -> Result<(), Self::Error>;
    fn shape(&self, node: &Self::Node) -> Result<Shape, Self::Error>;
    fn set_shape(
        &mut self,
        node: &Self::Node,
        shape: Shape,
    ) -> Result<(), Self::Error>;
    fn position(&self, node: &Self::Node) -> Result<Self::Position, Self::Error>;
    fn holds(
        &self,
        node: &Self::Node,
        compare: Compare,
        position: &Self::Position,
    ) -> Result<bool, Self::Error>;
    fn create(
        &mut self,
        position: &Self::Position,
    ) -> Result<Self::Node, Self::Error>;
    fn move_attributes(
        &mut self,
        from: &Self::Node,
        to: &Self::Node,
    ) -> Result<(), Self::Error>;
}
Expand description

The nodes of an AVL tree, however they are stored: what the steps of this module read and write of them.

Required Associated Types§

Source

type Node: Clone

A handle on one node.

Source

type Position

Where a node stands.

Source

type Error: From<TreeError>

What reading or writing a node can fail with.

Required Methods§

Source

fn left(&self, node: &Self::Node) -> Result<Option<Self::Node>, Self::Error>

The node’s left child.

Source

fn right(&self, node: &Self::Node) -> Result<Option<Self::Node>, Self::Error>

Its right child.

Source

fn set_left( &mut self, node: &Self::Node, child: Option<Self::Node>, ) -> Result<(), Self::Error>

Sets its left child.

Source

fn set_right( &mut self, node: &Self::Node, child: Option<Self::Node>, ) -> Result<(), Self::Error>

Sets its right child.

Source

fn shape(&self, node: &Self::Node) -> Result<Shape, Self::Error>

Its height and balance as last updated.

Source

fn set_shape( &mut self, node: &Self::Node, shape: Shape, ) -> Result<(), Self::Error>

Sets its height and balance.

Source

fn position(&self, node: &Self::Node) -> Result<Self::Position, Self::Error>

Its position.

Source

fn holds( &self, node: &Self::Node, compare: Compare, position: &Self::Position, ) -> Result<bool, Self::Error>

Whether node.position <compare> position.

Source

fn create( &mut self, position: &Self::Position, ) -> Result<Self::Node, Self::Error>

A new node at a position, holding nothing.

Source

fn move_attributes( &mut self, from: &Self::Node, to: &Self::Node, ) -> Result<(), Self::Error>

Moves what one node holds – its position and payload, not its links or shape – onto another: music21’s moveAttributes.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§