Class FixedStack

java.lang.Object
  |
  +--FixedStack

public class FixedStack
extends java.lang.Object
implements StackImpl

This class implements interface StackImpl with a stack represented by an array. Obviously, the stack has a fixed size and may overflow.


Field Summary
private  int[] data
           
private  int pnt
           
private  int size
           
 
Constructor Summary
FixedStack()
           
 
Method Summary
 int pop()
          Pop the stack.
 void push(int val)
          Push an integer onto the stack.
 int size()
          Return the number of elements contained in the stack.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

size

private final int size

data

private int[] data

pnt

private int pnt
Constructor Detail

FixedStack

public FixedStack()
Method Detail

push

public void push(int val)
Push an integer onto the stack.
Specified by:
push in interface StackImpl
Parameters:
val - The integer value pushed onto the stack.

pop

public int pop()
Pop the stack.
Specified by:
pop in interface StackImpl
Returns:
The integer value popped from the stack.

size

public int size()
Return the number of elements contained in the stack.
Specified by:
size in interface StackImpl
Returns:
The number of elements contained in the stack.