|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.datastructures.NodeStack<E>
public class NodeStack<E>
Implementation of the stack ADT by means of a singly linked list.
Node| Constructor Summary | |
|---|---|
NodeStack()
Creates an empty stack. |
|
| Method Summary | |
|---|---|
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: [ ... |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public NodeStack()
| Method Detail |
|---|
public int size()
size in interface Stack<E>public boolean isEmpty()
isEmpty in interface Stack<E>public void push(E elem)
push in interface Stack<E>element - to be inserted.
public E top()
throws EmptyStackException
top in interface Stack<E>EmptyStackException - if the stack is empty.
public E pop()
throws EmptyStackException
pop in interface Stack<E>EmptyStackException - if the stack is empty.public java.lang.String toString()
toString in class java.lang.Object
public static void status(Stack S,
java.lang.String op,
java.lang.Object element)
op - operation performedelement - element returned by the operationpublic static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||