From: jzhou Date: Sun, 6 Mar 2011 01:56:03 +0000 (+0000) Subject: Fix bugs in Class Library X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4101af89dbe6968df4e0a3673debf40404686f79;p=IRC.git Fix bugs in Class Library --- diff --git a/Robust/src/ClassLibrary/MGC/gnu/TreeMap.java b/Robust/src/ClassLibrary/MGC/gnu/TreeMap.java index 62a38418..c45d4cf3 100644 --- a/Robust/src/ClassLibrary/MGC/gnu/TreeMap.java +++ b/Robust/src/ClassLibrary/MGC/gnu/TreeMap.java @@ -412,7 +412,6 @@ public class TreeMap// extends AbstractMap */ 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// extends AbstractMap 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// extends AbstractMap */ 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// extends AbstractMap 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) diff --git a/Robust/src/ClassLibrary/MGC/gnu/TreeNode.java b/Robust/src/ClassLibrary/MGC/gnu/TreeNode.java index 11246dbf..8d625788 100644 --- a/Robust/src/ClassLibrary/MGC/gnu/TreeNode.java +++ b/Robust/src/ClassLibrary/MGC/gnu/TreeNode.java @@ -26,8 +26,8 @@ public static final class TreeNode// extends AbstractMap.SimpleEntry */ 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// extends AbstractMap.SimpleEntry TreeNode(int color) { - key = null; - value = null; + this.key = null; + this.value = null; this.color = color; } diff --git a/Robust/src/ClassLibrary/MGC/gnu/TreeSubMap.java b/Robust/src/ClassLibrary/MGC/gnu/TreeSubMap.java index 51a2089e..4489e379 100644 --- a/Robust/src/ClassLibrary/MGC/gnu/TreeSubMap.java +++ b/Robust/src/ClassLibrary/MGC/gnu/TreeSubMap.java @@ -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) {