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>
impl<K, V> Internal<K, V>
Sourcepub fn binary(
parent: Option<usize>,
left_id: usize,
median: Item<K, V>,
right_id: usize,
) -> Internal<K, V>
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).
pub fn is_overflowing(&self) -> bool
pub fn is_underflowing(&self) -> bool
pub fn parent(&self) -> Option<usize>
pub fn set_parent(&mut self, p: Option<usize>)
pub fn item_count(&self) -> usize
pub fn child_count(&self) -> usize
pub fn first_child_id(&self) -> usize
pub fn branches(&self) -> &[Branch<K, V>]
pub fn child_index(&self, id: usize) -> Option<usize>
pub fn child_id(&self, index: usize) -> usize
pub fn child_id_opt(&self, index: usize) -> Option<usize>
pub fn separators(&self, index: usize) -> (Option<&K>, Option<&K>)
pub fn get<Q>(&self, key: &Q) -> Result<&V, usize>
pub fn get_mut<Q>(&mut self, key: &Q) -> Result<&mut V, usize>
Sourcepub fn offset_of<Q>(&self, key: &Q) -> Result<Offset, (usize, usize)>
pub fn offset_of<Q>(&self, key: &Q) -> Result<Offset, (usize, usize)>
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.
pub fn children(&self) -> Children<'_, K, V> ⓘ
pub fn children_with_separators(&self) -> ChildrenWithSeparators<'_, K, V> ⓘ
pub fn item(&self, offset: Offset) -> Option<&Item<K, V>>
pub fn item_mut(&mut self, offset: Offset) -> Option<&mut Item<K, V>>
Sourcepub fn insert_by_key(
&mut self,
key: K,
value: V,
) -> Result<(Offset, V), InsertionError<K, V>>where
K: Ord,
pub fn insert_by_key(
&mut self,
key: K,
value: V,
) -> Result<(Offset, V), InsertionError<K, V>>where
K: Ord,
Insert by key.
Sourcepub fn insert(&mut self, offset: Offset, item: Item<K, V>, right_node_id: usize)
pub fn insert(&mut self, offset: Offset, item: Item<K, V>, right_node_id: usize)
Insert item at the given offset.
Sourcepub fn replace(&mut self, offset: Offset, item: Item<K, V>) -> Item<K, V>
pub fn replace(&mut self, offset: Offset, item: Item<K, V>) -> Item<K, V>
Replace the item at the given offset.
Sourcepub fn remove(&mut self, offset: Offset) -> (usize, Item<K, V>, usize)
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).
pub fn split(&mut self) -> (usize, Item<K, V>, Internal<K, V>)
Sourcepub fn merge(
&mut self,
left_index: usize,
right_index: usize,
) -> (usize, usize, usize, Item<K, V>, Balance)
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.