com.imaginary.util
Interface Stack

All Known Implementing Classes:
LifoStack, FifoStack

public abstract interface Stack

A generic interface for stacked collections. This interface prescribes methods that let you access objects in a collection based on some rule of order.
Last modified $Date: 1999/11/06 19:50:56 $


Method Summary
 boolean isEmpty()
           
 java.lang.Object peek()
          Provides a look at the next object on the stack without removing it.
 java.lang.Object pop()
          Removes the next object on the stack and returns it.
 java.lang.Object push(java.lang.Object ob)
          Places an object on the stack.
 int search(java.lang.Object ob)
          Provides the location of the specified object on the stack.
 int size()
           
 

Method Detail

isEmpty

public boolean isEmpty()
Returns:
true if there are no objects on the stack

peek

public java.lang.Object peek()
Provides a look at the next object on the stack without removing it.
Returns:
the next object on the stack

pop

public java.lang.Object pop()
Removes the next object on the stack and returns it.
Returns:
the next object on the stack

push

public java.lang.Object push(java.lang.Object ob)
Places an object on the stack.
Parameters:
ob - the object to be placed on the stack
Returns:
the object placed on the stack

search

public int search(java.lang.Object ob)
Provides the location of the specified object on the stack. The number 1 means the first object, 2 the second, and so on.
Returns:
the location of the object on the stack or -1 if it is not on the stack

size

public int size()
Returns:
the number of objects on the stack.