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

Method can_donate

python/bplustree/bplus_tree.py:702–705  ·  view source on GitHub ↗

Check if leaf can give a key to a sibling (has more than minimum).

(self)

Source from the content-addressed store, hash-verified

700 return len(self.keys) < min_keys
701
702 def can_donate(self) -> bool:
703 """Check if leaf can give a key to a sibling (has more than minimum)."""
704 min_keys = (self.capacity - 1) // 2
705 return len(self.keys) > min_keys
706
707 def borrow_from_left(self, left_sibling: "LeafNode") -> None:
708 """Borrow the rightmost key-value from left sibling"""

Callers 6

test_leaf_can_donateMethod · 0.95
_handle_underflowMethod · 0.45
borrow_from_leftMethod · 0.45
borrow_from_rightMethod · 0.45
borrow_from_leftMethod · 0.45
borrow_from_rightMethod · 0.45

Calls

no outgoing calls

Tested by 1

test_leaf_can_donateMethod · 0.76