2003/12/16 23:03:17
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:59 +0000 (07:42 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 07:42:59 +0000 (07:42 +0000)
darcs-hash:20040130074259-2ba56-94994e1d6508ef7beac70df2a5a5be959a69cb29.gz

src/org/xwt/util/BalancedTree.java

index 0f8b62e..175ae33 100644 (file)
@@ -30,7 +30,7 @@ public class BalancedTree {
     public final int treeSize() { return root == 0 ? 0 : size[root]; }
 
     /** clamps index to [0..treeSize()] and inserts object o *before* the specified index */
-    public final void insertNode(int index, Object o) {
+    public final synchronized void insertNode(int index, Object o) {
         cached_slot = cached_index = -1;
         if (index < 0) index = 0;
         if (index > treeSize()) index = treeSize();
@@ -46,7 +46,7 @@ public class BalancedTree {
     }
 
     /** clamps index to [0..treeSize()-1] and replaces the object at that index with object o */
-    public final void replaceNode(int index, Object o) {
+    public final synchronized void replaceNode(int index, Object o) {
         cached_slot = cached_index = -1;
         if (index < 0) index = 0;
         if (index > treeSize()) index = treeSize() - 1;
@@ -58,7 +58,7 @@ public class BalancedTree {
     }
 
     /** returns the index of o; runs in O((log n)^2) time unless cache hit */
-    public final int indexNode(Object o) { 
+    public final synchronized int indexNode(Object o) { 
         if (cached_slot != -1 && objects[cached_slot] == o) return cached_index;
 
         int slot = getSlot(o, o.hashCode() ^ this.hashCode());
@@ -70,7 +70,7 @@ public class BalancedTree {
     }
 
     /** returns the object at index; runs in O(log n) time unless cache hit */
-    public final Object getNode(int index) {
+    public final synchronized Object getNode(int index) {
         if (index == cached_index) return objects[cached_slot];
 
         if (cached_index != -1) {
@@ -93,7 +93,7 @@ public class BalancedTree {
     }
 
     /** deletes the object at index, returning the deleted object */
-    public final Object deleteNode(int index) {
+    public final synchronized Object deleteNode(int index) {
         cached_slot = cached_index = -1;
         int del = delete(index, root, 0);
         left[del] = right[del] = size[del] = 0;