get rid of JS.BT
[org.ibex.core.git] / src / org / ibex / js / JSArray.java
index 4777213..5afa82a 100644 (file)
@@ -5,8 +5,9 @@ import org.ibex.util.*;
 import java.util.*;
 
 /** A JavaScript JSArray */
-class JSArray extends JS.BT {
+class JSArray extends JS.O {
     private static final Object NULL = new Object();
+    private final BalancedTree bt = new BalancedTree();
     
     public JSArray() { }
     public JSArray(int size) { setSize(size); }
@@ -122,27 +123,27 @@ class JSArray extends JS.BT {
     public final int length() { return size(); }
     public final JS elementAt(int i) { 
         if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
-        Object o = getNode(i);
+        Object o = bt.getNode(i);
         return o == NULL ? (JS)null : (JS)o;
     }
     public final void addElement(JS o) { 
-        insertNode(size(),o==null ? NULL : o);
+        bt.insertNode(size(),o==null ? NULL : o);
     }
     public final void setElementAt(JS o, int i) {
         if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
-        replaceNode(i,o==null ? NULL : o);
+        bt.replaceNode(i,o==null ? NULL : o);
     }
     public final void insertElementAt(JS o, int i) {
         if(i < 0 || i > size()) throw new ArrayIndexOutOfBoundsException(i);
-        insertNode(i,o==null ? NULL : o);
+        bt.insertNode(i,o==null ? NULL : o);
     }
     public final JS removeElementAt(int i) {
         if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
-        Object o = deleteNode(i);
+        Object o = bt.deleteNode(i);
         return o == NULL ? (JS)null : (JS)o;
     }
     
-    public final int size() { return treeSize(); }
+    public final int size() { return bt.treeSize(); }
     
     private JS join(String sep) throws JSExn {
         int length = size();
@@ -163,7 +164,7 @@ class JSArray extends JS.BT {
         int size = size();
         if(size < 2) return this;
         Vec vec = toVec();
-        clear();
+        bt.clear();
         for(int i=size-1,j=0;i>=0;i--,j++) insertElementAt((JS)vec.elementAt(i),j);
         return this;
     }
@@ -246,7 +247,7 @@ class JSArray extends JS.BT {
         Vec vec = new Vec();
         vec.setSize(count);
         for(int i=0;i<count;i++) {
-            Object o = getNode(i);
+            Object o = bt.getNode(i);
             vec.setElementAt(o == NULL ? null : o,i);
         }
         return vec;
@@ -254,10 +255,10 @@ class JSArray extends JS.BT {
     
     protected void setFromVec(Vec vec) {
         int count = vec.size();
-        clear();
+        bt.clear();
         for(int i=0;i<count;i++) {
             Object o = vec.elementAt(i);
-            insertNode(i,o==null ? NULL : o);
+            bt.insertNode(i,o==null ? NULL : o);
         }
     }