com.imaginary.util
Class LifoStack

java.lang.Object
  |
  +--com.sun.java.util.collections.AbstractCollection
        |
        +--com.sun.java.util.collections.AbstractList
              |
              +--com.sun.java.util.collections.ArrayList
                    |
                    +--com.imaginary.util.LifoStack

public class LifoStack
extends com.sun.java.util.collections.ArrayList
implements Stack

An unsynchronized LIFO stack. This class provides easy access to pushing and popping objects to and from a stack where the rule is that the last object in is the first object out. As with most Java collections, this class is wholly unsynchronized.
Last modified $Date: 1999/11/06 19:50:52 $

See Also:
Serialized Form

Fields inherited from class com.sun.java.util.collections.AbstractList
modCount
 
Constructor Summary
LifoStack()
          Constructs an empty LIFO stack.
 
Method Summary
 java.lang.Object peek()
          Provides a look at the last object placed on the stack, since it will be the first one out.
 java.lang.Object pop()
          Pops the last object placed on the stack off of it and returns it.
 java.lang.Object push(java.lang.Object ob)
          Pushes a new object onto the stack.
 int search(java.lang.Object ob)
          Searches the stack for the specified object.
 
Methods inherited from class com.sun.java.util.collections.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class com.sun.java.util.collections.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class com.sun.java.util.collections.AbstractCollection
containsAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LifoStack

public LifoStack()
Constructs an empty LIFO stack.
Method Detail

peek

public java.lang.Object peek()
Provides a look at the last object placed on the stack, since it will be the first one out. This method does not change the contents of the stack. Because this class is unsynchronized, applications using this class are responsible for making sure that a peek() followed by a pop() returns the same value.
Specified by:
peek in interface Stack
Returns:
the object on the top of the stack

pop

public java.lang.Object pop()
Pops the last object placed on the stack off of it and returns it.
Specified by:
pop in interface Stack
Returns:
the last object placed on the stack

push

public java.lang.Object push(java.lang.Object ob)
Pushes a new object onto the stack.
Specified by:
push in interface Stack
Parameters:
ob - the new object
Returns:
the new object

search

public int search(java.lang.Object ob)
Searches the stack for the specified object. Returns the location of the object with respect to the top of the stack or -1.
Specified by:
search in interface Stack
Parameters:
ob - the object being sought
Returns:
the index of the object on the stack or -1.