Parsing Engine

danbikel.util
Class Stack

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by danbikel.util.Stack
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class Stack
extends ArrayList

A simple stack implementation created from an ArrayList.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Stack()
          Constructs an empty stack.
Stack(Collection c)
          Constructs a stack with the specified collection, whose bottom element is the first returned by c.iterator() and whose top element is the last.
Stack(int initialCapacity)
          Constructs a stack with the specified initial capacity.
 
Method Summary
 boolean empty()
          Returns true if this stack contains no elements.
 Object pop()
          Pops the top element off the stack.
 void push(Object obj)
          Pushes the specified object onto the stack.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

Stack

public Stack()
Constructs an empty stack.


Stack

public Stack(Collection c)
Constructs a stack with the specified collection, whose bottom element is the first returned by c.iterator() and whose top element is the last.


Stack

public Stack(int initialCapacity)
Constructs a stack with the specified initial capacity.

Method Detail

empty

public boolean empty()
Returns true if this stack contains no elements.


push

public void push(Object obj)
Pushes the specified object onto the stack.


pop

public Object pop()
Pops the top element off the stack.

Returns:
the top element that was popped off the stack
Throws:
IndexOutOfBoundsException - if this stack was empty prior to calling this method

Parsing Engine

Author: Dan Bikel.