Class QuickStack

java.lang.Object
org.exolab.adaptx.util.QuickStack

public class QuickStack extends Object
A representation of a Stack that does not use Synchronization. For compatibility this class supports the same methods as a java.util.Stack (JDK)
Version:
$Revision: 3633 $ $Date: 2003-03-01 08:38:44 +0100 (Sat, 01 Mar 2003) $
Author:
Keith Visco
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty Stack
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Tests for an empty Stack
    Returns an Iterator for this Stack.
    Returns the Object that is currently on top of the Stack.
    pop()
    Removes and returns the Object that is currently on top of the Stack.
    void
    push(Object object)
    Adds the given Object to the top of the Stack
    int
    search(Object object)
    Searches for the given Object in the stack and returns it's position relative to the top of the Stack (ie the number of calls to #pop() before the object is returned by #pop())
    int
    Returns the number of items on the Stack

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • QuickStack

      public QuickStack()
      Creates an empty Stack
  • Method Details

    • empty

      public boolean empty()
      Tests for an empty Stack
      Returns:
      true if there are no elements on the stack, otherwise false.
    • iterator

      public Iterator iterator()
      Returns an Iterator for this Stack. The iterator will iterate from the top of the stack, to the bottom
    • peek

      public Object peek() throws EmptyStackException
      Returns the Object that is currently on top of the Stack. Unlike #pop the Object is not removed from the Stack.
      Returns:
      the Object that is currently the top of the stack
      Throws:
      EmptyStackException - when there are no elements currently on the Stack
    • pop

      public Object pop() throws EmptyStackException
      Removes and returns the Object that is currently on top of the Stack.
      Returns:
      the Object that is currently the top of the stack
      Throws:
      EmptyStackException - when there are no elements currently on the Stack
    • push

      public void push(Object object)
      Adds the given Object to the top of the Stack
    • search

      public int search(Object object)
      Searches for the given Object in the stack and returns it's position relative to the top of the Stack (ie the number of calls to #pop() before the object is returned by #pop())
    • size

      public int size()
      Returns the number of items on the Stack
      Returns:
      the number of items on the Stack