From: brian Date: Sat, 10 Apr 2004 00:35:25 +0000 (+0000) Subject: another balancedtree fix X-Git-Tag: RC4~14 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;ds=sidebyside;h=bb26c9c5308bb6d0ec5554a357fc86085139ccb3;p=org.ibex.core.git another balancedtree fix darcs-hash:20040410003525-24bed-7931f23e7e5375bf87b967970ae1588d2b68d441.gz --- diff --git a/src/org/ibex/util/BalancedTree.java b/src/org/ibex/util/BalancedTree.java index 1c42ef1..36d8542 100644 --- a/src/org/ibex/util/BalancedTree.java +++ b/src/org/ibex/util/BalancedTree.java @@ -169,13 +169,14 @@ public class BalancedTree { // collisions when a single Object is inserted into multiple // trees int dest = Math.abs(o.hashCode() ^ this.hashCode()) % objects.length; + if (dest == 0) dest = 1; Object search = alloc ? null : o; int odest = dest; boolean plus = true; int tries = 1; while (objects[dest] != search || !(alloc || root(dest) == root)) { - if (dest == 0) dest++; dest = Math.abs((odest + (plus ? 1 : -1) * tries * tries) % objects.length); + if (dest == 0) dest=1; if (plus) tries++; plus = !plus; // FEATURE: GROW - if(tries > MAX_SLOT_DISTANCE) return -1;