Methods Summary |
---|
public void | clear()Clears the stack.
fDepth = 0;
|
public int | elementAt(int depth)Returns the element at the specified depth in the stack.
return fData[depth];
|
private void | ensureCapacity(int size)Ensures capacity.
if (fData == null) {
fData = new int[32];
}
else if (fData.length <= size) {
int[] newdata = new int[fData.length * 2];
System.arraycopy(fData, 0, newdata, 0, fData.length);
fData = newdata;
}
|
public int | peek()Peeks at the top of the stack.
return fData[fDepth - 1];
|
public int | pop()Pops a value off of the stack.
return fData[--fDepth];
|
public void | print()Prints the stack.
System.out.print('(");
System.out.print(fDepth);
System.out.print(") {");
for (int i = 0; i < fDepth; i++) {
if (i == 3) {
System.out.print(" ...");
break;
}
System.out.print(' ");
System.out.print(fData[i]);
if (i < fDepth - 1) {
System.out.print(',");
}
}
System.out.print(" }");
System.out.println();
|
public void | push(int value)Pushes a value onto the stack.
ensureCapacity(fDepth + 1);
fData[fDepth++] = value;
|
public int | size()Returns the size of the stack.
return fDepth;
|