|
datastructures | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.datastructures.NodeStack
Implementation of a stack by means of a singly linked list.
Node| Field Summary | |
protected int |
size
|
protected Node |
top
|
| Constructor Summary | |
NodeStack()
Creates an empty stack. |
|
| Method Summary | |
boolean |
isEmpty()
Return whether the stack is empty. |
Object |
pop()
Remove the top element from the stack. |
void |
push(Object elem)
Insert an element at the top of the stack. |
int |
size()
Return the number of elements in the stack. |
Object |
top()
Inspect the element at the top of the stack. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Node top
protected int size
| Constructor Detail |
public NodeStack()
| Method Detail |
public int size()
Stack
size in interface Stackpublic boolean isEmpty()
Stack
isEmpty in interface Stackpublic void push(Object elem)
Stack
push in interface Stackelem - element to be inserted.
public Object top()
throws EmptyStackException
Stack
top in interface StackEmptyStackException - if the stack is empty.
public Object pop()
throws EmptyStackException
Stack
pop in interface StackEmptyStackException - if the stack is empty.
|
datastructures | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||