fix(ranked_tree): transplant by double-delete
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
d8a746268b
commit
f67468b637
1 changed files with 3 additions and 11 deletions
|
@ -119,17 +119,9 @@ class RankedTree(Generic[T]):
|
|||
self._transplant(node, node.left)
|
||||
else:
|
||||
n = Node.minimum(node.right)
|
||||
y, parent = None, (n.parent if n.parent is not node else n)
|
||||
|
||||
if n.parent is not node:
|
||||
parent = n.right if n.right else n.parent
|
||||
self._transplant(n, n.right)
|
||||
n.right = node.right
|
||||
n.right.parent = n
|
||||
|
||||
self._transplant(node, n)
|
||||
n.left = node.left
|
||||
n.left.parent = n
|
||||
node.value = n.value
|
||||
n.value = None
|
||||
return self._delete_node(n)
|
||||
|
||||
return (y, parent)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue