MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / borrow_from_right

Method borrow_from_right

python/bplustree/bplus_tree.py:717–725  ·  view source on GitHub ↗

Borrow the leftmost key-value from right sibling

(self, right_sibling: "LeafNode")

Source from the content-addressed store, hash-verified

715 self.values.insert(0, value)
716
717 def borrow_from_right(self, right_sibling: "LeafNode") -> None:
718 """Borrow the leftmost key-value from right sibling"""
719 if not right_sibling.can_donate():
720 raise ValueError("Right sibling cannot donate")
721
722 key = right_sibling.keys.pop(0)
723 value = right_sibling.values.pop(0)
724 self.keys.append(key)
725 self.values.append(value)
726
727 def merge_with_right(self, right_sibling: "LeafNode") -> None:
728 """Merge this leaf with its right sibling"""

Callers 2

Calls 2

can_donateMethod · 0.45
popMethod · 0.45

Tested by 1