Internal

Struct Internal 

Source
pub struct Internal<K, V> { /* 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<K, V> Internal<K, V>

Source

pub fn binary( parent: Option<usize>, left_id: usize, median: Item<K, V>, right_id: usize, ) -> Internal<K, V>

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

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<usize>

Source

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

Source

pub fn item_count(&self) -> usize

Source

pub fn child_count(&self) -> usize

Source

pub fn first_child_id(&self) -> usize

Source

pub fn branches(&self) -> &[Branch<K, V>]

Source

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

Source

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

Source

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

Source

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

Source

pub fn get<Q>(&self, key: &Q) -> Result<&V, usize>
where K: Borrow<Q>, Q: Ord + ?Sized,

Source

pub fn get_mut<Q>(&mut self, key: &Q) -> Result<&mut V, usize>
where K: Borrow<Q>, Q: Ord + ?Sized,

Source

pub fn offset_of<Q>(&self, key: &Q) -> Result<Offset, (usize, usize)>
where K: Borrow<Q>, Q: Ord + ?Sized,

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<'_, K, V>

Source

pub fn children_with_separators(&self) -> ChildrenWithSeparators<'_, K, V>

Source

pub fn item(&self, offset: Offset) -> Option<&Item<K, V>>

Source

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

Source

pub fn insert_by_key( &mut self, key: K, value: V, ) -> Result<(Offset, V), InsertionError<K, V>>
where K: Ord,

Insert by key.

Source

pub fn insert(&mut self, offset: Offset, item: Item<K, V>, right_node_id: usize)

Insert item at the given offset.

Source

pub fn replace(&mut self, offset: Offset, item: Item<K, V>) -> Item<K, V>

Replace the item at the given offset.

Source

pub fn remove(&mut self, offset: Offset) -> (usize, Item<K, V>, usize)

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, Item<K, V>, Internal<K, V>)

Source

pub fn merge( &mut self, left_index: usize, right_index: usize, ) -> (usize, usize, usize, Item<K, V>, 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: Item<K, V>, child_id: usize)

Source

pub fn pop_left(&mut self) -> Result<(Item<K, V>, usize), WouldUnderflow>

Source

pub fn push_right(&mut self, item: Item<K, V>, child_id: usize) -> Offset

Source

pub fn pop_right( &mut self, ) -> Result<(Offset, Item<K, V>, usize), WouldUnderflow>

Source

pub fn append(&mut self, separator: Item<K, V>, other: Internal<K, V>) -> Offset

Source

pub fn validate(&self, parent: Option<usize>, min: Option<&K>, max: Option<&K>)
where K: Ord,

Trait Implementations§

Source§

impl<K: Clone, V: Clone> Clone for Internal<K, V>

Source§

fn clone(&self) -> Internal<K, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for Internal<K, V>
where K: Freeze, V: Freeze,

§

impl<K, V> RefUnwindSafe for Internal<K, V>

§

impl<K, V> Send for Internal<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for Internal<K, V>
where K: Sync, V: Sync,

§

impl<K, V> Unpin for Internal<K, V>
where K: Unpin, V: Unpin,

§

impl<K, V> UnwindSafe for Internal<K, V>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.