Methods Summary |
---|
public boolean | empty()Tests if this stack is empty.
return curIndex == 0;
|
public java.lang.Object | peek()Looks at the object at the top of this stack without removing it
from the stack.
Object top = null;
if (curIndex > 0) {
top = list.get(curIndex - 1);
}
return top;
|
public java.lang.Object | pop()Removes the object at the top of this stack and returns that
object as the value of this function.
if (curIndex > 0) {
curIndex -= 1;
return list.remove(curIndex);
}
return null;
|
public void | push(java.lang.Object obj)Pushes an item onto the top of this stack. This method will internally
add elements to the ArrayList if the stack is full.
list.add(curIndex, obj);
curIndex += 1;
|
public int | size()Provides the current size of the stack.
return curIndex;
|