public final class ALStack<E> extends java.lang.Object implements SizedIterable<E>
JSONStreamReader.
The stack is backed by an ArrayList.| Constructor and Description |
|---|
ALStack()
Create a new stack object.
|
ALStack(int initSize)
Create a new stack object with a given initial size.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEmpty()
Determine whether the stack is currently empty.
|
java.util.Iterator<E> |
iterator()
Returns an unmodifiable iterator over all the elements on the stack.
|
E |
peek()
Returns the most recent element on the stack without removing it.
|
E |
pop()
Pop the most recent element off the stack.
|
void |
push(E elem)
Push an element onto the stack.
|
int |
size()
Determine the number of elements on the stack.
|
java.lang.String |
toString()
Returns a string representing all the elements on the stack.
|
public ALStack()
public ALStack(int initSize)
initSize - the initial size of the stackpublic void push(E elem)
elem - the element to be pushedpublic E pop() throws java.util.EmptyStackException
java.util.EmptyStackException - there are no elements on the stackpublic E peek() throws java.util.EmptyStackException
java.util.EmptyStackException - there are no elements on the stackpublic boolean isEmpty()
isEmpty in interface SizedIterable<E>true if the stack is empty, otherwise falsepublic int size()
size in interface SizedIterable<E>public java.lang.String toString()
toString in class java.lang.Object