2003/11/30 02:15:58
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:29 +0000 (07:42 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:29 +0000 (07:42 +0000)
darcs-hash:20040130074229-2ba56-faef1a662e47df8e13ce65d84166d4aba8626680.gz

src/org/xwt/util/BalancedTree.java

index 09e97dc..0aebcde 100644 (file)
@@ -29,11 +29,14 @@ public class BalancedTree {
         if (index < 0) index = 0;
         if (index > treeSize()) index = treeSize();
         int arg = allocateSlot(o);
-        if (root != 0) { insert(index, arg, root, 0, false, false); return; }
-        root = arg;
-        left[arg] = 0;
-        right[arg] = 0;
-        size[root] = 1;
+        if (root != 0) {
+            insert(index, arg, root, 0, false, false);
+        } else {
+            root = arg;
+            left[arg] = 0;
+            right[arg] = 0;
+            size[root] = 1;
+        }
     }
 
     /** clamps index to [0..treeSize()-1] and replaces the object at that index with object o */
@@ -238,6 +241,7 @@ public class BalancedTree {
             if (slot == root) {
                 root = arg;
                 balance(slot, arg);
+                balance(arg, 0);
             } else {
                 (left[parent] == slot ? left : right)[parent] = arg;
                 balance(slot, arg);