Changed fixInsertion to always augment parent
This changes fixInsertion to always augment the node's parent, even if the initial call to augment() returns false, assuming "augment" is true. When we insert a node, we are supposed to ignore its initial state; thus, we ignore the return value of augment().
This commit is contained in:
@@ -242,11 +242,9 @@ public abstract class RedBlackNode<N extends RedBlackNode<N>> implements Compara
|
||||
if (!isRed) {
|
||||
throw new IllegalArgumentException("The node must be red");
|
||||
}
|
||||
boolean changed;
|
||||
boolean changed = augment;
|
||||
if (augment) {
|
||||
changed = augment();
|
||||
} else {
|
||||
changed = false;
|
||||
augment();
|
||||
}
|
||||
|
||||
RedBlackNode<N> node = this;
|
||||
@@ -569,7 +567,6 @@ public abstract class RedBlackNode<N extends RedBlackNode<N>> implements Compara
|
||||
parent.right = child;
|
||||
}
|
||||
}
|
||||
parent = null;
|
||||
child.isRed = false;
|
||||
if (child.parent != null) {
|
||||
N parent;
|
||||
@@ -590,7 +587,6 @@ public abstract class RedBlackNode<N extends RedBlackNode<N>> implements Compara
|
||||
parent.right = leaf;
|
||||
sibling = parent.left;
|
||||
}
|
||||
this.parent = null;
|
||||
if (!isRed) {
|
||||
RedBlackNode<N> siblingNode = sibling;
|
||||
siblingNode.fixSiblingDeletion();
|
||||
|
||||
Reference in New Issue
Block a user