com.marringtons.string
Class StringStack

java.lang.Object
  extended bycom.marringtons.string.StringStack

public class StringStack
extends Object

This class implement a stack with String keys and values.

 stack = new StringStack();
 stack.push( "one");
 stack.isEmpty() == false;
 stack.size() == 1;
 stack.push( "two");
 stack.peek().equals( "two");
 stack.pop().equals( "two");
 stack.peek().equals( "one");
 stack.clear();
 stack.isEmpty() == true;
 

Author:
Paul Marrington

Constructor Summary
StringStack()
           
 
Method Summary
 void clear()
          Empty stack - releasing all references.
 boolean isEmpty()
          Return true only if the stack is devoid of items.
 String peek()
          Return the string on the top of the stack (without changint the stack pointer).
 String pop()
          Pop a string from the stack.
 void push(Object item)
          Push a string onto the stack (enlarging it if necessary).
 int size()
          Return the number of items currently on the stack.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringStack

public StringStack()
Method Detail

push

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

Parameters:
item - to push

pop

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

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

peek

public String 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()
Return the number of items currently on the stack.

Returns:
the number if items on the stack.

isEmpty

public boolean isEmpty()
Return true only if the stack is devoid of items.

Returns:
true if the stack is empty.

clear

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



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