|
|
@ -29,7 +29,7 @@ class RBTree<T extends Comparable<T>> { |
|
|
|
Node parent = null; |
|
|
|
|
|
|
|
// Traverse the tree to the left or right depending on the key, |
|
|
|
// finding a correct postion for the insertion of nodes later + keep the structure of the tree |
|
|
|
// finding a correct position for the insertion of nodes later + keep the structure of the tree |
|
|
|
while (node != null) { |
|
|
|
parent = node; |
|
|
|
if (key.compareTo(node.key) < 0) { // key < node.key |
|
|
@ -165,9 +165,6 @@ class RBTree<T extends Comparable<T>> { |
|
|
|
throw new IllegalStateException("Node is not a child of its parent"); |
|
|
|
} |
|
|
|
|
|
|
|
if (rightChild != null) { |
|
|
|
rightChild.parent = parent; |
|
|
|
} |
|
|
|
|
|
|
|
RootBlack(); |
|
|
|
|
|
|
@ -197,10 +194,6 @@ class RBTree<T extends Comparable<T>> { |
|
|
|
throw new IllegalStateException("Node is not a child of its parent"); |
|
|
|
} |
|
|
|
|
|
|
|
if (leftChild != null) { |
|
|
|
leftChild.parent = parent; |
|
|
|
} |
|
|
|
|
|
|
|
RootBlack(); |
|
|
|
|
|
|
|
return leftChild; |
|
|
|