Changed createTree to set root's parent to null

This changes createTree to set the "parent" field of the root node to null.
This commit is contained in:
Bill Jacobs
2016-06-06 14:55:58 -07:00
parent cd4424b94a
commit 8c98d5cc42
2 changed files with 2 additions and 0 deletions

Binary file not shown.

View File

@@ -24,6 +24,7 @@ import java.util.Set;
*
* @param <N> The type of node in the tree. For example, we might have "class FooNode<T> extends
* RedBlackNode<FooNode<T>>".
* @author Bill Jacobs
*/
public abstract class RedBlackNode<N extends RedBlackNode<N>> implements Comparable<N> {
/** A Comparator that compares Comparable elements using their natural order. */
@@ -720,6 +721,7 @@ public abstract class RedBlackNode<N extends RedBlackNode<N>> implements Compara
height++;
}
N node = createTree(nodes.iterator(), size, height, leaf);
node.parent = null;
node.isRed = false;
return node;
}