From: megacz Date: Fri, 30 Jan 2004 07:42:29 +0000 (+0000) Subject: 2003/11/30 02:15:58 X-Git-Tag: RC3~291 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=0a09ecaed4fe0898e881cf9413e39d715b7f3d46 2003/11/30 02:15:58 darcs-hash:20040130074229-2ba56-faef1a662e47df8e13ce65d84166d4aba8626680.gz --- diff --git a/src/org/xwt/util/BalancedTree.java b/src/org/xwt/util/BalancedTree.java index 09e97dc..0aebcde 100644 --- a/src/org/xwt/util/BalancedTree.java +++ b/src/org/xwt/util/BalancedTree.java @@ -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);