Struct BalancingContext
pub(in ::collections::btree) struct BalancingContext<'a, K, V> { pub(in ::collections::btree::node) parent: Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>, pub(in ::collections::btree::node) left_child: NodeRef<Mut<'a>, K, V, LeafOrInternal>, pub(in ::collections::btree::node) right_child: NodeRef<Mut<'a>, K, V, LeafOrInternal> }
Represents a session for evaluating and performing a balancing operation around an internal key-value pair.
Fields
parent: Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>left_child: NodeRef<Mut<'a>, K, V, LeafOrInternal>right_child: NodeRef<Mut<'a>, K, V, LeafOrInternal>
Implementations
impl<'a, K, V> BalancingContext<'a, K, V>
fn left_child_len(&self) -> usizefn right_child_len(&self) -> usizefn into_left_child(self) -> NodeRef<Mut<'a>, K, V, LeafOrInternal>fn into_right_child(self) -> NodeRef<Mut<'a>, K, V, LeafOrInternal>fn can_merge(&self) -> boolReturns whether merging is possible, i.e., whether there is enough room in a node to combine the central KV with both adjacent child nodes.
impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V>
fn do_merge<F: FnOnce(NodeRef<Mut<'a>, K, V, Internal>, NodeRef<Mut<'a>, K, V, LeafOrInternal>) -> R, R, A: Allocator>(self, result: F, alloc: A) -> RPerforms a merge and lets a closure decide what to return.
fn merge_tracking_parent<A: Allocator + Clone>(self, alloc: A) -> NodeRef<Mut<'a>, K, V, Internal>Merges the parent's key-value pair and both adjacent child nodes into the left child node and returns the shrunk parent node.
Panics unless we
.can_merge().fn merge_tracking_child<A: Allocator + Clone>(self, alloc: A) -> NodeRef<Mut<'a>, K, V, LeafOrInternal>Merges the parent's key-value pair and both adjacent child nodes into the left child node and returns that child node.
Panics unless we
.can_merge().fn merge_tracking_child_edge<A: Allocator + Clone>(self, track_edge_idx: LeftOrRight<usize>, alloc: A) -> Handle<NodeRef<Mut<'a>, K, V, LeafOrInternal>, Edge>Merges the parent's key-value pair and both adjacent child nodes into the left child node and returns the edge handle in that child node where the tracked child edge ended up,
Panics unless we
.can_merge().fn steal_left(self, track_right_edge_idx: usize) -> Handle<NodeRef<Mut<'a>, K, V, LeafOrInternal>, Edge>Removes a key-value pair from the left child and places it in the key-value storage of the parent, while pushing the old parent key-value pair into the right child. Returns a handle to the edge in the right child corresponding to where the original edge specified by
track_right_edge_idxended up.fn steal_right(self, track_left_edge_idx: usize) -> Handle<NodeRef<Mut<'a>, K, V, LeafOrInternal>, Edge>Removes a key-value pair from the right child and places it in the key-value storage of the parent, while pushing the old parent key-value pair onto the left child. Returns a handle to the edge in the left child specified by
track_left_edge_idx, which didn't move.fn bulk_steal_left(&mut self, count: usize)This does stealing similar to
steal_leftbut steals multiple elements at once.fn bulk_steal_right(&mut self, count: usize)The symmetric clone of
bulk_steal_left.
Auto Trait Implementations
impl<'a, K, V> !UnwindSafe for BalancingContext<'a, K, V>
impl<'a, K, V> Freeze for BalancingContext<'a, K, V>
where
Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>: Freeze,
NodeRef<Mut<'a>, K, V, LeafOrInternal>: Freeze + Freeze,
impl<'a, K, V> RefUnwindSafe for BalancingContext<'a, K, V>
where
Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>: RefUnwindSafe,
NodeRef<Mut<'a>, K, V, LeafOrInternal>: RefUnwindSafe + RefUnwindSafe,
impl<'a, K, V> Send for BalancingContext<'a, K, V>
where
Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>: Send,
NodeRef<Mut<'a>, K, V, LeafOrInternal>: Send + Send,
impl<'a, K, V> Sync for BalancingContext<'a, K, V>
where
Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>: Sync,
NodeRef<Mut<'a>, K, V, LeafOrInternal>: Sync + Sync,
impl<'a, K, V> Unpin for BalancingContext<'a, K, V>
where
Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>: Unpin,
NodeRef<Mut<'a>, K, V, LeafOrInternal>: Unpin + Unpin,
impl<'a, K, V> UnsafeUnpin for BalancingContext<'a, K, V>
where
Handle<NodeRef<Mut<'a>, K, V, Internal>, KV>: UnsafeUnpin,
NodeRef<Mut<'a>, K, V, LeafOrInternal>: UnsafeUnpin + UnsafeUnpin,
Blanket Implementations
impl<T> Any for BalancingContext<'a, K, V>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for BalancingContext<'a, K, V>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for BalancingContext<'a, K, V>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for BalancingContext<'a, K, V>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for BalancingContext<'a, K, V>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for BalancingContext<'a, K, V>
impl<T, U> Into<U> for BalancingContext<'a, K, V>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for BalancingContext<'a, K, V>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for BalancingContext<'a, K, V>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>