home *** CD-ROM | disk | FTP | other *** search
- package COM.objectspace.jgl;
-
- import java.util.Enumeration;
-
- public class Array implements Sequence {
- Object[] myStorage;
- int myLength;
- static final int DEFAULT_SIZE = 10;
- static final int THRESHOLD = 2000;
- static final int MULTIPLIER = 2;
-
- public Array() {
- this.myStorage = new Object[10];
- }
-
- public Array(int var1) {
- if (var1 < 0) {
- throw new IllegalArgumentException("Attempt to create an Array with a negative size");
- } else {
- this.myLength = var1;
- this.myStorage = new Object[this.myLength];
- }
- }
-
- public Array(int var1, Object var2) {
- this(var1);
-
- for(int var3 = 0; var3 < this.myLength; ++var3) {
- this.myStorage[var3] = var2;
- }
-
- }
-
- public Array(Object[] var1) {
- synchronized(var1){}
-
- try {
- this.myStorage = var1;
- this.myLength = var1.length;
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public Array(Array var1) {
- synchronized(var1){}
-
- try {
- this.myLength = var1.myLength;
- this.myStorage = new Object[this.myLength];
- System.arraycopy(var1.myStorage, 0, this.myStorage, 0, this.myLength);
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public synchronized Object clone() {
- return new Array(this);
- }
-
- public boolean equals(Object var1) {
- return var1 instanceof Array && this.equals((Array)var1);
- }
-
- public synchronized boolean equals(Array var1) {
- synchronized(var1){}
-
- boolean var2;
- try {
- var2 = this.size() == var1.size() && Comparing.equal(this.start(), this.finish(), var1.start());
- } catch (Throwable var8) {
- throw var8;
- }
-
- return var2;
- }
-
- public synchronized int hashCode() {
- return Hashing.orderedHash(this.start(), this.finish());
- }
-
- public synchronized String toString() {
- return "Array" + Printing.toString(this.start(), this.finish());
- }
-
- public synchronized void copy(Array var1) {
- if (this != var1) {
- synchronized(var1){}
-
- try {
- if (var1.myLength > this.myStorage.length) {
- this.myStorage = new Object[var1.myLength];
- System.arraycopy(var1.myStorage, 0, this.myStorage, 0, var1.myLength);
- } else if (this.myLength > var1.myLength) {
- System.arraycopy(var1.myStorage, 0, this.myStorage, 0, var1.myLength);
-
- for(int var4 = var1.myLength; var4 < this.myLength; ++var4) {
- this.myStorage[var4] = null;
- }
- } else {
- System.arraycopy(var1.myStorage, 0, this.myStorage, 0, var1.myLength);
- }
-
- this.myLength = var1.myLength;
- } catch (Throwable var6) {
- throw var6;
- }
-
- }
- }
-
- public synchronized void copyTo(Object[] var1) {
- synchronized(var1){}
-
- try {
- if (this.myLength < var1.length) {
- System.arraycopy(this.myStorage, 0, var1, 0, this.myLength);
- } else {
- System.arraycopy(this.myStorage, 0, var1, 0, var1.length);
- }
- } catch (Throwable var4) {
- throw var4;
- }
-
- }
-
- public boolean isEmpty() {
- return this.myLength == 0;
- }
-
- public int size() {
- return this.myLength;
- }
-
- public int maxSize() {
- return Integer.MAX_VALUE;
- }
-
- public int capacity() {
- return this.myStorage.length;
- }
-
- public synchronized Object back() {
- if (this.myLength == 0) {
- throw new InvalidOperationException("Array is empty");
- } else {
- return this.myStorage[this.myLength - 1];
- }
- }
-
- public synchronized Object front() {
- if (this.myLength == 0) {
- throw new InvalidOperationException("Array is empty");
- } else {
- return this.myStorage[0];
- }
- }
-
- // $FF: renamed from: at (int) java.lang.Object
- public synchronized Object method_0(int var1) {
- if (var1 >= 0 && var1 < this.myLength) {
- return this.myStorage[var1];
- } else {
- throw new IndexOutOfBoundsException("Attempt to access index " + var1 + " when valid range is 0.." + (this.myLength - 1));
- }
- }
-
- public synchronized void put(int var1, Object var2) {
- if (var1 >= this.myLength) {
- throw new IndexOutOfBoundsException("Attempt to access index " + var1 + " when valid range is 0.." + (this.myLength - 1));
- } else {
- this.myStorage[var1] = var2;
- }
- }
-
- public synchronized void clear() {
- this.myStorage = new Object[10];
- this.myLength = 0;
- }
-
- public Object remove(Enumeration var1) {
- if (!(var1 instanceof ArrayIterator)) {
- throw new IllegalArgumentException("Enumeration not an ArrayIterator");
- } else if (((ArrayIterator)var1).myArray != this) {
- throw new IllegalArgumentException("Enumeration not for this Array ");
- } else {
- ArrayIterator var2 = (ArrayIterator)var1;
- Object var3 = var2.myArray.method_0(var2.myIndex);
- this.remove(((ArrayIterator)var1).myIndex);
- return var3;
- }
- }
-
- public synchronized Object remove(int var1) {
- if (var1 >= 0 && var1 < this.myLength) {
- Object var2 = this.myStorage[var1];
- System.arraycopy(this.myStorage, var1 + 1, this.myStorage, var1, this.myLength - var1 - 1);
- this.myStorage[--this.myLength] = null;
- return var2;
- } else {
- throw new IndexOutOfBoundsException("Attempt to access index " + var1 + " when valid range is 0.." + (this.myLength - 1));
- }
- }
-
- public int remove(Enumeration var1, Enumeration var2) {
- if (var1 instanceof ArrayIterator && var2 instanceof ArrayIterator) {
- if (((ArrayIterator)var1).myArray == this && ((ArrayIterator)var2).myArray == this) {
- return this.remove(((ArrayIterator)var1).myIndex, ((ArrayIterator)var2).myIndex - 1);
- } else {
- throw new IllegalArgumentException("Enumeration not for this Array ");
- }
- } else {
- throw new IllegalArgumentException("Enumeration not an ArrayIterator");
- }
- }
-
- public synchronized int remove(int var1, int var2) {
- if (var2 < var1) {
- return 0;
- } else {
- this.checkRange(var1, var2);
- int var3 = var2 - var1 + 1;
- System.arraycopy(this.myStorage, var2 + 1, this.myStorage, var1, this.myLength - var2 - 1);
-
- for(int var4 = this.myLength - var3; var4 < this.myLength; ++var4) {
- this.myStorage[var4] = null;
- }
-
- this.myLength -= var3;
- return var3;
- }
- }
-
- public synchronized Object popBack() {
- if (this.myLength == 0) {
- throw new InvalidOperationException("Array is empty");
- } else {
- Object var1 = this.myStorage[--this.myLength];
- this.myStorage[this.myLength] = null;
- return var1;
- }
- }
-
- public synchronized Object add(Object var1) {
- if (this.myLength == this.myStorage.length) {
- Object[] var2 = this.getNextStorage();
- System.arraycopy(this.myStorage, 0, var2, 0, this.myLength);
- this.myStorage = var2;
- }
-
- this.myStorage[this.myLength++] = var1;
- return null;
- }
-
- public void pushBack(Object var1) {
- this.add(var1);
- }
-
- public ArrayIterator insert(ArrayIterator var1, Object var2) {
- this.insert(var1.myIndex, var2);
- return new ArrayIterator(this, var1.myIndex);
- }
-
- public synchronized void insert(int var1, Object var2) {
- if (var1 > this.myLength) {
- throw new IndexOutOfBoundsException("Attempt to insert at index " + var1 + " when valid range is 0.." + this.myLength);
- } else {
- if (this.myLength != this.myStorage.length) {
- if (var1 != this.myLength) {
- System.arraycopy(this.myStorage, var1, this.myStorage, var1 + 1, this.myLength - var1);
- }
- } else {
- Object[] var3 = this.getNextStorage();
- System.arraycopy(this.myStorage, 0, var3, 0, var1);
- System.arraycopy(this.myStorage, var1, var3, var1 + 1, this.myLength - var1);
- this.myStorage = var3;
- }
-
- this.myStorage[var1] = var2;
- ++this.myLength;
- }
- }
-
- public void insert(ArrayIterator var1, int var2, Object var3) {
- this.insert(var1.myIndex, var2, var3);
- }
-
- public synchronized void insert(int var1, int var2, Object var3) {
- if (var1 >= 0 && var1 <= this.myLength) {
- if (var2 < 0) {
- throw new IllegalArgumentException("Attempt to insert a negative number of objects.");
- } else if (var2 != 0) {
- if (this.myStorage.length - this.myLength >= var2) {
- System.arraycopy(this.myStorage, var1, this.myStorage, var1 + var2, this.myLength - var1);
- } else {
- Object[] var4 = this.getNextStorage(var2);
- System.arraycopy(this.myStorage, 0, var4, 0, var1);
- System.arraycopy(this.myStorage, var1, var4, var1 + var2, this.myLength - var1);
- this.myStorage = var4;
- }
-
- for(int var5 = var1; var5 < var1 + var2; ++var5) {
- this.myStorage[var5] = var3;
- }
-
- this.myLength += var2;
- }
- } else {
- throw new IndexOutOfBoundsException("Attempt to insert at index " + var1 + " when valid range is 0.." + this.myLength);
- }
- }
-
- public void insert(ArrayIterator var1, ForwardIterator var2, ForwardIterator var3) {
- this.insert(var1.myIndex, var2, var3);
- }
-
- public synchronized void insert(int var1, ForwardIterator var2, ForwardIterator var3) {
- int var4 = var2.distance(var3);
- if (var4 != 0) {
- ForwardIterator var5 = (ForwardIterator)var2.clone();
- if (this.myStorage.length - this.myLength >= var4) {
- System.arraycopy(this.myStorage, var1, this.myStorage, var1 + var4, this.myLength - var1);
- } else {
- Object[] var6 = this.getNextStorage(var4);
- System.arraycopy(this.myStorage, 0, var6, 0, var1);
- System.arraycopy(this.myStorage, var1, var6, var1 + var4, this.myLength - var1);
- this.myStorage = var6;
- }
-
- for(int var7 = var1; var7 < var1 + var4; ++var7) {
- this.myStorage[var7] = var5.nextElement();
- }
-
- this.myLength += var4;
- }
- }
-
- public synchronized void swap(Array var1) {
- synchronized(var1){}
-
- try {
- int var4 = this.myLength;
- Object[] var5 = this.myStorage;
- this.myLength = var1.myLength;
- this.myStorage = var1.myStorage;
- var1.myLength = var4;
- var1.myStorage = var5;
- } catch (Throwable var7) {
- throw var7;
- }
-
- }
-
- public synchronized Enumeration elements() {
- return new ArrayIterator(this, 0);
- }
-
- public ForwardIterator start() {
- return this.begin();
- }
-
- public ForwardIterator finish() {
- return this.end();
- }
-
- public synchronized ArrayIterator begin() {
- return new ArrayIterator(this, 0);
- }
-
- public synchronized ArrayIterator end() {
- return new ArrayIterator(this, this.myLength);
- }
-
- public synchronized void trimToSize() {
- if (this.myLength < this.myStorage.length) {
- Object[] var1 = this.myStorage;
- this.myStorage = new Object[this.myLength];
- System.arraycopy(var1, 0, this.myStorage, 0, this.myLength);
- }
-
- }
-
- public synchronized void ensureCapacity(int var1) {
- if (var1 < 0) {
- throw new IllegalArgumentException("Attempt to reserve a negative size.");
- } else {
- if (this.myStorage.length < var1) {
- Object[] var2 = new Object[var1];
- if (this.myLength > 0) {
- System.arraycopy(this.myStorage, 0, var2, 0, this.myLength);
- }
-
- this.myStorage = var2;
- }
-
- }
- }
-
- public synchronized Object popFront() {
- if (this.myLength == 0) {
- throw new InvalidOperationException("Array is empty");
- } else {
- Object var1 = this.myStorage[0];
- this.remove(0);
- return var1;
- }
- }
-
- public void pushFront(Object var1) {
- this.insert(0, var1);
- }
-
- public int remove(Object var1) {
- return this.remove(0, this.myLength - 1, var1);
- }
-
- public synchronized int remove(Object var1, int var2) {
- int var3 = 0;
-
- while(var2 > 0) {
- int var4 = this.indexOf(var1);
- if (var4 >= 0) {
- --var2;
- ++var3;
- this.remove(var4);
- }
- }
-
- return var3;
- }
-
- public synchronized int remove(int var1, int var2, Object var3) {
- if (var2 < var1) {
- return 0;
- } else {
- this.checkRange(var1, var2);
- ArrayIterator var4 = new ArrayIterator(this, var1);
- ArrayIterator var5 = new ArrayIterator(this, var2 + 1);
- ArrayIterator var6 = (ArrayIterator)Removing.remove(var4, var5, var3);
- return this.remove(var6.myIndex, var2);
- }
- }
-
- public synchronized int replace(Object var1, Object var2) {
- return Replacing.replace(this.start(), this.finish(), var1, var2);
- }
-
- public synchronized int replace(int var1, int var2, Object var3, Object var4) {
- if (var2 < var1) {
- return 0;
- } else {
- this.checkRange(var1, var2);
- return Replacing.replace(new ArrayIterator(this, var1), new ArrayIterator(this, var2 + 1), var3, var4);
- }
- }
-
- public synchronized int count(Object var1) {
- return Counting.count(this.start(), this.finish(), var1);
- }
-
- public synchronized int count(int var1, int var2, Object var3) {
- if (var2 < var1) {
- return 0;
- } else {
- this.checkRange(var1, var2);
- return Counting.count(new ArrayIterator(this, var1), new ArrayIterator(this, var2 + 1), var3);
- }
- }
-
- public int indexOf(Object var1) {
- return this.indexOf(0, this.myLength - 1, var1);
- }
-
- public synchronized int indexOf(int var1, int var2, Object var3) {
- if (var2 < var1) {
- return -1;
- } else {
- this.checkRange(var1, var2);
- int var4 = ((ArrayIterator)Finding.find(new ArrayIterator(this, var1), new ArrayIterator(this, var2 + 1), var3)).myIndex;
- return var4 == var2 + 1 ? -1 : var4;
- }
- }
-
- public synchronized void setSize(int var1) {
- if (this.myLength > var1) {
- this.remove(var1, this.myLength - 1);
- } else {
- if (this.myLength < var1) {
- this.insert(this.myLength, var1 - this.myLength, (Object)null);
- }
-
- }
- }
-
- public boolean contains(Object var1) {
- return this.indexOf(var1) != -1;
- }
-
- private void checkRange(int var1, int var2) {
- if (var1 >= 0 && var1 < this.myLength) {
- if (var2 < 0 || var2 >= this.myLength) {
- throw new IndexOutOfBoundsException("Attempt to access index " + var2 + " when valid range is 0.." + (this.myLength - 1));
- }
- } else {
- throw new IndexOutOfBoundsException("Attempt to access index " + var1 + " when valid range is 0.." + (this.myLength - 1));
- }
- }
-
- private int getNextSize() {
- int var1 = this.myLength > 2000 ? this.myLength + 2000 : this.myLength * 2;
- return Math.max(1, var1);
- }
-
- private Object[] getNextStorage() {
- Object[] var1 = new Object[this.getNextSize()];
- return var1;
- }
-
- private Object[] getNextStorage(int var1) {
- int var2 = Math.max(this.getNextSize(), this.myLength + var1);
- Object[] var3 = new Object[var2];
- return var3;
- }
- }
-