X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSArray.java;h=a9483d0dbc490b13972a060cdf02fd545f354921;hp=d0cd550e333f5dca8d53fb4e40858e79a2840fc9;hb=2c7492501427a4876792cc12492d2185a605d7c4;hpb=85c8f402be33df8440511492fb597fba9c2eb45f diff --git a/src/org/ibex/js/JSArray.java b/src/org/ibex/js/JSArray.java index d0cd550..a9483d0 100644 --- a/src/org/ibex/js/JSArray.java +++ b/src/org/ibex/js/JSArray.java @@ -5,8 +5,9 @@ import org.ibex.util.*; import java.util.*; /** A JavaScript JSArray */ -public class JSArray extends JS.BT { +public 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 @@ public 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 @@ public 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 @@ public class JSArray extends JS.BT { Vec vec = new Vec(); vec.setSize(count); for(int i=0;i