| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.mhhe.clrs2e.StackArray
Implements an elementary stack from page 201 of Introduction to Algorithms, Second edition.
| Field Summary | |
protected static int | 
EMPTY
The index of the top when thestack is empty.  | 
protected  java.lang.Object[] | 
stack
The array implementing the stack.  | 
protected  int | 
top
The index of the top of the stack.  | 
| Constructor Summary | |
StackArray()
Makes an empty stack with 1 slot.  | 
|
StackArray(int size)
Makes an empty stack with a given number of slots.  | 
|
| Method Summary | |
 boolean | 
isEmpty()
Returns true if the stack is empty,
 false otherwise. | 
 java.lang.Object | 
pop()
Pops an object from the stack, returning the popped object.  | 
 void | 
push(java.lang.Object x)
Pushes an object onto the stack.  | 
| Methods inherited from class java.lang.Object | 
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
protected int top
protected java.lang.Object[] stack
protected static final int EMPTY
| Constructor Detail | 
public StackArray()
public StackArray(int size)
size - The number of slots.| Method Detail | 
public boolean isEmpty()
true if the stack is empty,
 false otherwise.
isEmpty in interface Stackpublic void push(java.lang.Object x)
push in interface Stackx - Object to be pushed.public java.lang.Object pop()
pop in interface StackStackUnderflowException - if the stack was already empty.
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||