JS no longer automatically extends BalancedTree
authoradam <adam@megacz.com>
Thu, 23 Sep 2004 04:40:10 +0000 (04:40 +0000)
committeradam <adam@megacz.com>
Thu, 23 Sep 2004 04:40:10 +0000 (04:40 +0000)
darcs-hash:20040923044010-5007d-52f163ad4d28c911465b0551cc2edab4d06e5ef6.gz

src/org/ibex/js/JS.java
src/org/ibex/js/JSArray.java

index 1e38ce5..f6b1583 100644 (file)
@@ -6,7 +6,7 @@ import java.io.*;
 import java.util.*;
 
 /** The minimum set of functionality required for objects which are manipulated by JavaScript */
-public class JS extends org.ibex.util.BalancedTree { 
+public class JS /*extends org.ibex.util.BalancedTree*/{ 
 
     public static boolean checkAssertions = false;
 
index 7b90de7..dfb9714 100644 (file)
@@ -7,6 +7,8 @@ import java.util.*;
 /** A JavaScript JSArray */
 public class JSArray extends JS {
     private static final Object NULL = new Object();
+
+    private BalancedTree arr = new BalancedTree();
     
     public JSArray() { }
     public JSArray(int size) { setSize(size); }
@@ -118,27 +120,27 @@ public class JSArray extends JS {
     public final int length() { return size(); }
     public final Object elementAt(int i) { 
         if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
-        Object o = getNode(i);
+        Object o = arr.getNode(i);
         return o == NULL ? null : o;
     }
     public final void addElement(Object o) { 
-        insertNode(size(),o==null ? NULL : o);
+        arr.insertNode(size(),o==null ? NULL : o);
     }
     public final void setElementAt(Object o, int i) {
         if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
-        replaceNode(i,o==null ? NULL : o);
+        arr.replaceNode(i,o==null ? NULL : o);
     }
     public final void insertElementAt(Object o, int i) {
         if(i < 0 || i > size()) throw new ArrayIndexOutOfBoundsException(i);
-        insertNode(i,o==null ? NULL : o);
+        arr.insertNode(i,o==null ? NULL : o);
     }
     public final Object removeElementAt(int i) {
         if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
-        Object o = deleteNode(i);
+        Object o = arr.deleteNode(i);
         return o == NULL ? null : o;
     }
     
-    public final int size() { return treeSize(); }
+    public final int size() { return arr.treeSize(); }
     public String typeName() { return "array"; }
         
     private Object join(String sep) {
@@ -160,7 +162,7 @@ public class JSArray extends JS {
         int size = size();
         if(size < 2) return this;
         Vec vec = toVec();
-        clear();
+        arr.clear();
         for(int i=size-1,j=0;i>=0;i--,j++) insertElementAt(vec.elementAt(i),j);
         return this;
     }
@@ -243,7 +245,7 @@ public class JSArray extends JS {
         Vec vec = new Vec();
         vec.setSize(count);
         for(int i=0;i<count;i++) {
-            Object o = getNode(i);
+            Object o = arr.getNode(i);
             vec.setElementAt(o == NULL ? null : o,i);
         }
         return vec;
@@ -251,10 +253,10 @@ public class JSArray extends JS {
     
     protected void setFromVec(Vec vec) {
         int count = vec.size();
-        clear();
+        arr.clear();
         for(int i=0;i<count;i++) {
             Object o = vec.elementAt(i);
-            insertNode(i,o==null ? NULL : o);
+            arr.insertNode(i,o==null ? NULL : o);
         }
     }