summaryrefslogtreecommitdiff
path: root/java/util/TreeMap.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/util/TreeMap.java')
-rw-r--r--java/util/TreeMap.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/java/util/TreeMap.java b/java/util/TreeMap.java
index e03887833..9ab90f77e 100644
--- a/java/util/TreeMap.java
+++ b/java/util/TreeMap.java
@@ -130,7 +130,7 @@ public class TreeMap<K, V> extends AbstractMap<K, V>
/**
* The root node of this TreeMap.
*/
- private transient Node root = nil;
+ private transient Node root;
/**
* The size of this TreeMap. Package visible for use by nested classes.
@@ -213,6 +213,7 @@ public class TreeMap<K, V> extends AbstractMap<K, V>
public TreeMap(Comparator<? super K> c)
{
comparator = c;
+ fabricateTree(0);
}
/**
@@ -851,7 +852,11 @@ public class TreeMap<K, V> extends AbstractMap<K, V>
private void fabricateTree(final int count)
{
if (count == 0)
- return;
+ {
+ root = nil;
+ size = 0;
+ return;
+ }
// We color every row of nodes black, except for the overflow nodes.
// I believe that this is the optimal arrangement. We construct the tree