com.marringtons.number
Class IntegerStack

java.lang.Object
  extended bycom.marringtons.number.IntegerStack

public class IntegerStack
extends Object

This is an implement a stack for integer primatives.

 stack = new IntegerStack();
 stack.push( 1);
 stack.isEmpty() == false;
 stack.size() == 1;
 stack.push( 2);
 stack.peek() == 2;
 stack.pop() == 2;
 stack.peek() == 1;
 stack.clear();
 stack.isEmpty() == true;
 int[] stackArray = stack.getStack();
 

Author:
Paul Marrington

Constructor Summary
IntegerStack()
           
 
Method Summary
 void clear()
          Empty stack - releasing all references.
 boolean isEmpty()
          Check to see if the stack has entries.
 int peek()
          Return the string on the top of the stack (without changint the stack pointer).
 int pop()
          Pop a string from the stack.
 void push(int item)
          Push a string onto the stack (enlarging it if necessary).
 int size()
          Find out how many entries are on the stack.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntegerStack

public IntegerStack()
Method Detail

push

public void push(int item)
Push a string onto the stack (enlarging it if necessary).

Parameters:
item - to push

pop

public int pop()
Pop a string from the stack.

Returns:
most recently added item or null if stack is empty

peek

public int peek()
Return the string on the top of the stack (without changint the stack pointer).

Returns:
most recently added item or null if stack is empty

size

public int size()
Find out how many entries are on the stack.

Returns:
the number if items on the stack.

isEmpty

public boolean isEmpty()
Check to see if the stack has entries.

Returns:
true if the stack is empty.

clear

public void clear()
Empty stack - releasing all references.



Copyright © 2005 Paul Marrington http://library.marringtons.com