home *** CD-ROM | disk | FTP | other *** search
- import java.io.PrintStream;
-
- public class JSbxIndexArray extends JSbxBase {
- private static final int MIN_SIZE_STEP = 5;
- private static final int MAX_SIZE_STEP = 10000;
- private static final int DEFAULT_SIZE_STEP = 20;
- protected Object[] aObjects;
- protected int nCapacity;
- protected int nSize;
- protected int nOffset;
- protected int nSizeStep;
-
- public JSbxIndexArray() {
- this.ImpInit(20);
- }
-
- public JSbxIndexArray(int var1) {
- this.ImpInit(var1);
- }
-
- private final void ImpInit(int var1) {
- this.nCapacity = 0;
- this.nSize = 0;
- this.nOffset = 0;
- this.SetSizeStep(var1);
- }
-
- public final void Put(int var1, Object var2) {
- this.ChangeSizeForNewIndex(var1);
- this.aObjects[var1 + this.nOffset] = var2;
- if (this.nSize <= var1) {
- this.nSize = var1 + 1;
- }
-
- }
-
- public final void Add(Object var1) {
- this.Put(this.nSize, var1);
- }
-
- public final Object Get(int var1) {
- return this.nSize > var1 && -this.nOffset <= var1 ? this.aObjects[var1 + this.nOffset] : null;
- }
-
- public final Object GetLast() {
- Object var1 = null;
- if (this.nSize > 0) {
- var1 = this.aObjects[this.nSize - 1 + this.nOffset];
- }
-
- return var1;
- }
-
- public final Object DeleteLast() {
- Object var1 = null;
- if (this.nSize > 0) {
- --this.nSize;
- var1 = this.aObjects[this.nSize + this.nOffset];
- this.aObjects[this.nSize + this.nOffset] = null;
- }
-
- return var1;
- }
-
- public final void Clear() {
- while(this.nSize > 0) {
- --this.nSize;
- this.aObjects[this.nSize + this.nOffset] = null;
- }
-
- while(this.nOffset >= 0) {
- this.aObjects[this.nOffset] = null;
- --this.nOffset;
- }
-
- }
-
- private final void ChangeSizeForNewIndex(int var1) {
- if (var1 + this.nOffset >= this.nCapacity || var1 < this.GetMinIndex()) {
- int var4 = this.nCapacity / this.nSizeStep;
- int var5 = this.GetMinIndex();
- int var3;
- if (var1 < this.GetMinIndex()) {
- var3 = 1 + (var5 - var1) / this.nSizeStep;
- this.nOffset += var3 * this.nSizeStep;
- } else {
- var3 = 1 + (var1 - var5 - this.nCapacity) / this.nSizeStep;
- }
-
- int var2 = this.nSizeStep * (var3 + var4);
- Object[] var6 = new Object[var2];
- if (this.aObjects != null) {
- for(int var7 = 0; var7 < this.nSize - var5; ++var7) {
- var6[var7 + this.nOffset + var5] = this.aObjects[var7];
- }
- }
-
- this.aObjects = var6;
- this.nCapacity = this.aObjects.length;
- }
-
- }
-
- public final int GetTotalSize() {
- return this.nSize + this.nOffset;
- }
-
- public final int GetMinIndex() {
- return -this.nOffset;
- }
-
- public final int GetMaxIndex() {
- return this.nSize - 1;
- }
-
- public final int GetSize() {
- return this.nSize + this.nOffset;
- }
-
- public final int GetPosIndexSize() {
- return this.nSize;
- }
-
- private final void SetSizeStep(int var1) {
- if (var1 < 5) {
- var1 = 5;
- } else if (var1 > 10000) {
- var1 = 10000;
- }
-
- this.nSizeStep = var1;
- }
-
- public final void Reverse() {
- int var2 = this.aObjects.length;
- Object[] var3 = new Object[var2];
-
- for(int var1 = 0; var1 < var2; ++var1) {
- var3[var1] = this.aObjects[var1];
- }
-
- for(int var4 = 0; var4 < this.GetPosIndexSize(); ++var4) {
- var3[this.GetPosIndexSize() - var4 - 1 + this.nOffset] = this.aObjects[var4 + this.nOffset];
- }
-
- this.aObjects = var3;
- }
-
- public void Dump(PrintStream var1, int var2, int var3) throws JSbxException {
- if (this.aObjects != null) {
- String var4 = JSbxBase.GetTabStr(var2);
-
- for(int var5 = 0; var5 < this.nSize + this.nOffset; ++var5) {
- int var6 = var5 - this.nOffset;
- var1.print(var4 + "[" + var6 + "] = ");
- if (this.aObjects[var5] instanceof JSbxBase) {
- ((JSbxBase)this.aObjects[var5 + this.nOffset]).Dump(var1, var2, var3);
- } else {
- var1.println("null");
- }
- }
-
- }
- }
- }
-