Enum btree_slab::generic::node::Node
source · pub enum Node<K, V> {
Internal(InternalNode<K, V>),
Leaf(LeafNode<K, V>),
}
Expand description
B-tree node.
Variants§
Implementations§
source§impl<K, V> Node<K, V>
impl<K, V> Node<K, V>
pub fn binary( parent: Option<usize>, left_id: usize, median: Item<K, V>, right_id: usize ) -> Node<K, V>
pub fn leaf(parent: Option<usize>, item: Item<K, V>) -> Node<K, V>
pub fn balance(&self) -> Balance
pub fn is_underflowing(&self) -> bool
pub fn is_overflowing(&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 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 get<Q>(&self, key: &Q) -> Result<Option<&V>, usize>where K: Borrow<Q>, Q: Ord + ?Sized,
pub fn get_mut<Q>(&mut self, key: &Q) -> Result<Option<&mut V>, usize>where K: Borrow<Q>, Q: Ord + ?Sized,
sourcepub fn offset_of<Q>(&self, key: &Q) -> Result<Offset, (usize, Option<usize>)>where
K: Borrow<Q>,
Q: Ord + ?Sized,
pub fn offset_of<Q>(&self, key: &Q) -> Result<Offset, (usize, Option<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,
or Err(None)
if it is a leaf.
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, Option<V>), InsertionError<K, V>>where
K: Ord,
pub fn insert_by_key( &mut self, key: K, value: V ) -> Result<(Offset, Option<V>), InsertionError<K, V>>where K: Ord,
Insert by key.
It is assumed that the node is not free. If it is a leaf node, there must be a free space in it for the inserted value.
sourcepub fn split(&mut self) -> (usize, Item<K, V>, Node<K, V>)
pub fn split(&mut self) -> (usize, Item<K, V>, Node<K, V>)
Split the node. Return the length of the node after split, the median item and the right node.
pub fn merge( &mut self, left_index: usize, right_index: usize ) -> (usize, usize, usize, Item<K, V>, Balance)
sourcepub fn append(&mut self, separator: Item<K, V>, other: Node<K, V>) -> Offset
pub fn append(&mut self, separator: Item<K, V>, other: Node<K, V>) -> Offset
Return the offset of the separator.
pub fn push_left(&mut self, item: Item<K, V>, opt_child_id: Option<usize>)
pub fn pop_left( &mut self ) -> Result<(Item<K, V>, Option<usize>), WouldUnderflow>
pub fn push_right( &mut self, item: Item<K, V>, opt_child_id: Option<usize> ) -> Offset
pub fn pop_right(&mut self) -> Result<PoppedItem<K, V>, WouldUnderflow>
pub fn leaf_remove( &mut self, offset: Offset ) -> Option<Result<Item<K, V>, usize>>
pub fn remove_rightmost_leaf(&mut self) -> Result<Item<K, V>, usize>
sourcepub fn insert(
&mut self,
offset: Offset,
item: Item<K, V>,
opt_right_child_id: Option<usize>
)
pub fn insert( &mut self, offset: Offset, item: Item<K, V>, opt_right_child_id: Option<usize> )
Put an item in a node.
It is assumed that the node will not overflow.
pub fn replace(&mut self, offset: Offset, item: Item<K, V>) -> Item<K, V>
pub fn separators(&self, i: usize) -> (Option<&K>, Option<&K>)
pub fn children(&self) -> Children<'_, K, V> ⓘ
pub fn children_with_separators(&self) -> ChildrenWithSeparators<'_, K, V> ⓘ
pub fn validate(&self, parent: Option<usize>, min: Option<&K>, max: Option<&K>)where K: Ord,
Trait Implementations§
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for Node<K, V>where K: RefUnwindSafe, V: RefUnwindSafe,
impl<K, V> Send for Node<K, V>where K: Send, V: Send,
impl<K, V> Sync for Node<K, V>where K: Sync, V: Sync,
impl<K, V> Unpin for Node<K, V>where K: Unpin, V: Unpin,
impl<K, V> UnwindSafe for Node<K, V>where K: UnwindSafe + RefUnwindSafe, V: UnwindSafe + RefUnwindSafe,
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