- public final void setSize(int newSize) {
- // FEATURE: This could be done a lot more efficiently in BalancedTree
- int oldSize = size();
- for(int i=oldSize;i<newSize;i++) insertElementAt(null,i);
- for(int i=oldSize-1;i>=newSize;i--) removeElementAt(i);
- }
-
- public final int length() { return size(); }
- public final Object elementAt(int i) {
- if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
- Object o = arr.getNode(i);
- return o == NULL ? null : o;
- }
- public final void addElement(Object 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);
- arr.replaceNode(i,o==null ? NULL : o);
- }
- public final void insertElementAt(Object o, int i) {
- if(i < 0 || i > size()) throw new ArrayIndexOutOfBoundsException(i);
- arr.insertNode(i,o==null ? NULL : o);
- }
- public final Object removeElementAt(int i) {
- if(i < 0 || i >= size()) throw new ArrayIndexOutOfBoundsException(i);
- Object o = arr.deleteNode(i);
- return o == NULL ? null : o;
+ /** FEATURE: move to specialised ArrayStore superclass. */
+ public void addAll(JS[] entries) { for (int i=0; i < entries.length; i++) add(entries[i]); }
+
+ public void setSize(int newSize) {
+ size(newSize);
+ for (int i=size(); i < newSize; i++) add(null);
+ for (int i=size() - 1; i >= newSize; i--) remove(i);