Internal

Struct Internal 

Source
pub struct Internal<T, S: Storage<T>> { /* private fields */ }
Expand description

Internal node.

An internal node is a node where each item is surrounded by edges to child nodes.

Implementations§

Source§

impl<T, S: Storage<T>> Internal<T, S>

Source

pub fn new( parent: Option<S::Node>, first_child: S::Node, other_children: Array<Branch<T, S>, M>, ) -> Self

Source

pub fn binary( parent: Option<S::Node>, left_id: S::Node, median: T, right_id: S::Node, ) -> Internal<T, S>

Creates a binary node (with a single item and two children).

Source

pub fn forget(&mut self)

Forget the node content, without running the items destructors.

The node’s children must be manually dropped.

Source

pub fn balance(&self) -> Balance

Returns the current balance of the node.

Source

pub fn is_overflowing(&self) -> bool

Source

pub fn is_underflowing(&self) -> bool

Source

pub fn parent(&self) -> Option<S::Node>

Source

pub fn set_parent(&mut self, p: Option<S::Node>)

Source

pub fn item_count(&self) -> usize

Source

pub fn child_count(&self) -> usize

Source

pub fn first_child_id(&self) -> S::Node

Source

pub fn branches(&self) -> &[Branch<T, S>]

Source

pub fn child_index(&self, id: S::Node) -> Option<usize>

Source

pub fn child_id(&self, index: usize) -> S::Node

Source

pub fn child_id_opt(&self, index: usize) -> Option<S::Node>

Source

pub fn separators(&self, index: usize) -> (Option<&T>, Option<&T>)

Source

pub fn get<Q: ?Sized>( &self, cmp: impl Fn(&T, &Q) -> Ordering, key: &Q, ) -> Result<&T, S::Node>

Source

pub fn get_mut<Q: ?Sized>( &mut self, cmp: impl Fn(&T, &Q) -> Ordering, key: &Q, ) -> Result<&mut T, &mut S::Node>

Source

pub fn offset_of<Q: ?Sized>( &self, cmp: impl Fn(&T, &Q) -> Ordering, key: &Q, ) -> Result<Offset, (usize, S::Node)>

Find the offset of the item matching the given key.

If the key matches no item in this node, this funtion returns the index and id of the child that may match the key.

Source

pub fn children(&self) -> Children<'_, T, S>

Source

pub fn children_with_separators(&self) -> ChildrenWithSeparators<'_, T, S>

Source

pub fn item(&self, offset: Offset) -> Option<&T>

Source

pub fn item_mut(&mut self, offset: Offset) -> Option<&mut T>

Source

pub fn insert_by_key( &mut self, cmp: impl Fn(&T, &T) -> Ordering, item: T, ) -> Result<(Offset, T), InsertionError<T, S>>

Insert by key.

Source

pub fn insert(&mut self, offset: Offset, item: T, right_node_id: S::Node)

Insert item at the given offset.

Source

pub fn replace(&mut self, offset: Offset, item: T) -> T

Replace the item at the given offset.

Source

pub fn remove(&mut self, offset: Offset) -> (S::Node, T, S::Node)

Remove the item at the given offset. Return the child id on the left of the item, the item, and the child id on the right (which is also removed).

Source

pub fn split(&mut self) -> (usize, T, Internal<T, S>)

Source

pub fn merge( &mut self, left_index: usize, ) -> (usize, S::Node, S::Node, T, Balance)

Merge the children at the given indexes.

It is supposed that left_index is right_index-1. This method returns the identifier of the left node in the tree, the identifier of the right node, the item removed from this node to be merged with the merged children and the balance status of this node after the merging operation.

Source

pub fn push_left(&mut self, item: T, child_id: S::Node)

Source

pub fn pop_left(&mut self) -> Result<(T, S::Node), WouldUnderflow>

Source

pub fn push_right(&mut self, item: T, child_id: S::Node) -> Offset

Source

pub fn pop_right(&mut self) -> Result<RightBranch<T, S>, WouldUnderflow>

Source

pub fn append(&mut self, separator: T, other: Internal<T, S>) -> Offset

Source

pub fn validate( &self, cmp: impl Fn(&T, &T) -> Ordering, parent: Option<S::Node>, min: Option<&T>, max: Option<&T>, )

Auto Trait Implementations§

§

impl<T, S> Freeze for Internal<T, S>
where <S as Storage<T>>::Node: Freeze, T: Freeze,

§

impl<T, S> RefUnwindSafe for Internal<T, S>
where <S as Storage<T>>::Node: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, S> Send for Internal<T, S>
where <S as Storage<T>>::Node: Send, T: Send,

§

impl<T, S> Sync for Internal<T, S>
where <S as Storage<T>>::Node: Sync, T: Sync,

§

impl<T, S> Unpin for Internal<T, S>
where <S as Storage<T>>::Node: Unpin, T: Unpin,

§

impl<T, S> UnwindSafe for Internal<T, S>
where <S as Storage<T>>::Node: UnwindSafe, 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.