Redistribute keys from left sibling to child
(self, parent: "BranchNode", child_index: int)
| 323 | self._merge_with_sibling(parent, child_index) |
| 324 | |
| 325 | def _redistribute_from_left(self, parent: "BranchNode", child_index: int) -> None: |
| 326 | """Redistribute keys from left sibling to child""" |
| 327 | child = parent.children[child_index] |
| 328 | left_sibling = parent.children[child_index - 1] |
| 329 | |
| 330 | if child.is_leaf(): |
| 331 | # Leaf redistribution |
| 332 | child.borrow_from_left(left_sibling) |
| 333 | # Update separator key in parent |
| 334 | parent.keys[child_index - 1] = child.keys[0] |
| 335 | else: |
| 336 | # Branch redistribution |
| 337 | separator_key = parent.keys[child_index - 1] |
| 338 | new_separator = child.borrow_from_left(left_sibling, separator_key) |
| 339 | parent.keys[child_index - 1] = new_separator |
| 340 | |
| 341 | def _redistribute_from_right(self, parent: "BranchNode", child_index: int) -> None: |
| 342 | """Redistribute keys from right sibling to child""" |
no test coverage detected