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:
Bill Jacobs
2016-05-31 23:07:52 -07:00
parent 4e1fe67095
commit deb397ed1e
2 changed files with 2 additions and 6 deletions

View File

@@ -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();