2003/11/29 19:50:55
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:25 +0000 (07:42 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:25 +0000 (07:42 +0000)
darcs-hash:20040130074225-2ba56-479ddb3544e32d1e496dced16f4cbb7c6ed89cfa.gz

src/org/xwt/util/BalancedTree.java

index 988351d..e37e3f8 100644 (file)
@@ -208,6 +208,17 @@ public class BalancedTree {
 
         if (size[arg] != 0) throw new Error("double insertion");
 
+        if (replace) {
+            if (diff == 0) {
+                objects[slot] = objects[arg];
+                objects[arg] = null;
+                left[arg] = right[arg] = size[arg] = 0;
+            } else {
+                // since we already clamped the index
+                throw new Error("this should never happen");
+            }
+        }
+
         // we become the child of a former leaf
         if (slot <= 0) {
             int[] left = wentLeft ? BalancedTree.left : BalancedTree.right;