MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / leaf_remove

Method leaf_remove

cranelift/bforest/src/node.rs:334–351  ·  view source on GitHub ↗

Remove the key-value pair at `index` from this leaf node. Return an indication of the node's health (i.e. below half capacity).

(&mut self, index: usize)

Source from the content-addressed store, hash-verified

332 ///
333 /// Return an indication of the node's health (i.e. below half capacity).
334 pub fn leaf_remove(&mut self, index: usize) -> Removed {
335 match *self {
336 Self::Leaf {
337 ref mut size,
338 ref mut keys,
339 ref mut vals,
340 } => {
341 let sz = usize::from(*size);
342 let keys = keys.borrow_mut();
343 let vals = vals.borrow_mut();
344 *size -= 1;
345 slice_shift(&mut keys[index..sz], 1);
346 slice_shift(&mut vals[index..sz], 1);
347 Removed::new(index, sz - 1, keys.len())
348 }
349 _ => panic!("Expected leaf node"),
350 }
351 }
352
353 /// Balance this node with its right sibling.
354 ///

Callers 1

removeMethod · 0.80

Calls 4

fromFunction · 0.85
slice_shiftFunction · 0.85
newFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected