projects
/
org.ibex.core.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9533ff4
)
2003/12/10 01:41:17
author
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 07:42:42 +0000
(07:42 +0000)
committer
megacz
<megacz@xwt.org>
Fri, 30 Jan 2004 07:42:42 +0000
(07:42 +0000)
darcs-hash:
20040130074242
-2ba56-
5a131fd719d778fa0f7e85f1d032d27a5dae46ce
.gz
src/org/xwt/util/BalancedTree.java
patch
|
blob
|
history
diff --git
a/src/org/xwt/util/BalancedTree.java
b/src/org/xwt/util/BalancedTree.java
index
e442db3
..
0f8b62e
100644
(file)
--- a/
src/org/xwt/util/BalancedTree.java
+++ b/
src/org/xwt/util/BalancedTree.java
@@
-66,7
+66,7
@@
public class BalancedTree {
if (parent == 0) return size(left[slot]); // we are on the far left edge
// all nodes after parent and before us are in our left subtree
if (parent == 0) return size(left[slot]); // we are on the far left edge
// all nodes after parent and before us are in our left subtree
- return size(left[slot]) + indexNode(objects[parent]) + 1;
+ return size(left[slot]) + (parent <= 0 ? 0 : indexNode(objects[parent])) + 1;
}
/** returns the object at index; runs in O(log n) time unless cache hit */
}
/** returns the object at index; runs in O(log n) time unless cache hit */
@@
-310,7
+310,7
@@
public class BalancedTree {
} else {
int left_childs_rightmost = delete(size(left[slot]) - 1, left[slot], slot);
left[left_childs_rightmost] = left[slot];
} else {
int left_childs_rightmost = delete(size(left[slot]) - 1, left[slot], slot);
left[left_childs_rightmost] = left[slot];
- left[left_childs_rightmost] = right[slot];
+ right[left_childs_rightmost] = right[slot];
if (parent == 0) root = left_childs_rightmost;
else (left[parent] == slot ? left : right)[parent] = left_childs_rightmost; // fix parent's pointer
balance(left_childs_rightmost, parent);
if (parent == 0) root = left_childs_rightmost;
else (left[parent] == slot ? left : right)[parent] = left_childs_rightmost; // fix parent's pointer
balance(left_childs_rightmost, parent);