Constructor and Description |
---|
NodeStack()
Creates an empty stack.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isEmpty()
Return whether the stack is empty.
|
static void |
main(java.lang.String[] args)
Test program that performs a series of operations on on a stack and
prints the operation performed, the returned element and the
content of the stack after each operation.
|
E |
pop()
Remove the top element from the stack.
|
void |
push(E elem)
Insert an element at the top of the stack.
|
int |
size()
Return the number of elements in the stack.
|
static void |
status(Stack S,
java.lang.String op,
java.lang.Object element)
Prints information about an operation and the stack.
|
E |
top()
Inspect the element at the top of the stack.
|
java.lang.String |
toString()
Returns a string representation of the stack as a list of elements,
with the top element at the end: [ ...
|
public boolean isEmpty()
Stack
public static void main(java.lang.String[] args)
public E pop() throws EmptyStackException
Stack
pop
in interface Stack<E>
EmptyStackException
- if the stack is empty.public void push(E elem)
Stack
public int size()
Stack
public static void status(Stack S, java.lang.String op, java.lang.Object element)
op
- operation performedelement
- element returned by the operationpublic E top() throws EmptyStackException
Stack
top
in interface Stack<E>
EmptyStackException
- if the stack is empty.public java.lang.String toString()
toString
in class java.lang.Object