Class DynamicStack

java.lang.Object
  |
  +--DynamicStack
All Implemented Interfaces:
IntStack

public class DynamicStack
extends java.lang.Object
implements IntStack

DynamicStacks of ints can store a potentially unbounded # of integers.


Field Summary
protected  int curSize
           
protected  int nFree
           
 
Constructor Summary
DynamicStack()
          Default constructor with initial stack size set to defaultInitialSize
DynamicStack(int initSize)
          Constructor.
 
Method Summary
 int pop()
          Pops the topmost item from the stack.
 void push(int item)
          Should never overflow unless you need to buy more memory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

curSize

protected int curSize

nFree

protected int nFree
Constructor Detail

DynamicStack

public DynamicStack(int initSize)
Constructor.

Parameters:
initSize - specifies how big the initial stack should be

DynamicStack

public DynamicStack()
Default constructor with initial stack size set to defaultInitialSize

Method Detail

push

public void push(int item)
Should never overflow unless you need to buy more memory.

Specified by:
push in interface IntStack
Parameters:
item - the thing to be pushed

pop

public int pop()
Description copied from interface: IntStack
Pops the topmost item from the stack. Underflow is handled by the implementation.

Specified by:
pop in interface IntStack
Returns:
the topmost items