Fix bugs in Class Library
authorjzhou <jzhou>
Sun, 6 Mar 2011 01:56:03 +0000 (01:56 +0000)
committerjzhou <jzhou>
Sun, 6 Mar 2011 01:56:03 +0000 (01:56 +0000)
Robust/src/ClassLibrary/MGC/gnu/TreeMap.java
Robust/src/ClassLibrary/MGC/gnu/TreeNode.java
Robust/src/ClassLibrary/MGC/gnu/TreeSubMap.java

index 62a3841889cde5ff66393be046ec4f052fb8ffbd..c45d4cf3adb4342cb1fc6585f1e6f61d8b49dc38 100644 (file)
@@ -412,7 +412,6 @@ public class TreeMap//<K, V> extends AbstractMap<K, V>
    */
   public Object put(Object key, Object value)
   {
-    System.out.println("TreeMap.put() " + (String)root.key);
     TreeNode current = root;
     TreeNode parent = nil;
     int comparison = 0;
@@ -443,14 +442,14 @@ public class TreeMap//<K, V> extends AbstractMap<K, V>
         root = n;
         return null;
       }
-    if (comparison > 0)
+    if (comparison > 0) {
       parent.right = n;
-    else
+    } else {
       parent.left = n;
+    }
 
     // Rebalance after insert.
     insertFixup(n);
-    System.out.println("==== " + (String)root.key);
     return null;
   }
 
@@ -1022,7 +1021,6 @@ public class TreeMap//<K, V> extends AbstractMap<K, V>
    */
   final TreeNode lowestGreaterThan(Object key, boolean first, boolean equal)
   {
-    System.out.println("TreeMap.lowestGreaterThan(Object, boolean, boolean)() " + (String)key + " " + (String)root.key);
     if (key == nil)
       return first ? firstNode() : nil;
 
@@ -1032,10 +1030,8 @@ public class TreeMap//<K, V> extends AbstractMap<K, V>
 
     while (current != nil)
       {
-      System.out.println("AAAA");
         last = current;
         comparison = compare(key, current.key);
-        System.out.println(comparison);
         if (comparison > 0)
           current = current.right;
         else if (comparison < 0)
index 11246dbfa90a75f1ac02599fe1d538ef2290eddd..8d625788c3538cc7b77d2ced34c34b5667db307c 100644 (file)
@@ -26,8 +26,8 @@ public static final class TreeNode//<K, V> extends AbstractMap.SimpleEntry<K, V>
    */
   TreeNode(Object key, Object value, int color)
   {
-    key = key;
-    value = value;
+    this.key = key;
+    this.value = value;
     this.color = color;
     left = TreeMap.nil;
     right = TreeMap.nil;
@@ -36,8 +36,8 @@ public static final class TreeNode//<K, V> extends AbstractMap.SimpleEntry<K, V>
   
   TreeNode(int color)
   {
-    key = null;
-    value = null;
+    this.key = null;
+    this.value = null;
     this.color = color;
   }
 
index 51a2089e19b10abf549d976d87501cebb916a4ea..4489e379e1cad2a0b357ca624b20c41071348639 100644 (file)
@@ -29,16 +29,12 @@ public final class TreeSubMap
       throw new /*IllegalArgument*/Exception("IllegalArgumentException: fromKey > toKey");
     this.minKey = minKey;
     this.maxKey = maxKey;
-    System.out.println("TreeSubMap() " + (String)this.minKey + " " + (String)this.maxKey);
   }
 
   public int size()
   {
-    System.out.println("TreeSubMap.size() " + (String)this.minKey + " " + (String)this.maxKey);
     TreeNode node = map.lowestGreaterThan(minKey, true);
     TreeNode max = map.lowestGreaterThan(maxKey, false);
-    System.out.println((String)node.key);
-    System.out.println((String)max.key);
     int count = 0;
     while (node != max)
     {