Save This Page
Home » commons-collections-3.2.1-src » org.apache.commons » collections » [javadoc | source]
org.apache.commons.collections
public class: ArrayStack [javadoc | source]
java.lang.Object
   java.util.AbstractCollection
      java.util.AbstractList
         java.util.ArrayList
            org.apache.commons.collections.ArrayStack

All Implemented Interfaces:
    Buffer, List, Serializable, RandomAccess, Cloneable, Collection

An implementation of the java.util.Stack API that is based on an ArrayList instead of a Vector, so it is not synchronized to protect against multi-threaded access. The implementation is therefore operates faster in environments where you do not need to worry about multiple thread contention.

The removal order of an ArrayStack is based on insertion order: The most recently added element is removed first. The iteration order is not the same as the removal order. The iterator returns elements from the bottom up, whereas the #remove() method removes them from the top down.

Unlike Stack, ArrayStack accepts null entries.

Constructor:
 public ArrayStack() 
 public ArrayStack(int initialSize) 
Method from org.apache.commons.collections.ArrayStack Summary:
empty,   get,   peek,   peek,   pop,   push,   remove,   search
Methods from java.util.ArrayList:
add,   add,   addAll,   addAll,   clear,   clone,   contains,   ensureCapacity,   get,   indexOf,   isEmpty,   lastIndexOf,   remove,   remove,   set,   size,   toArray,   toArray,   trimToSize
Methods from java.util.AbstractList:
add,   add,   addAll,   clear,   equals,   get,   hashCode,   indexOf,   iterator,   lastIndexOf,   listIterator,   listIterator,   remove,   set,   subList
Methods from java.util.AbstractCollection:
add,   addAll,   clear,   contains,   containsAll,   isEmpty,   iterator,   remove,   removeAll,   retainAll,   size,   toArray,   toArray,   toString
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.commons.collections.ArrayStack Detail:
 public boolean empty() 
    Return true if this stack is currently empty.

    This method exists for compatibility with java.util.Stack. New users of this class should use isEmpty instead.

 public Object get() 
    Returns the element on the top of the stack.
 public Object peek() throws EmptyStackException 
    Returns the top item off of this stack without removing it.
 public Object peek(int n) throws EmptyStackException 
    Returns the n'th item down (zero-relative) from the top of this stack without removing it.
 public Object pop() throws EmptyStackException 
    Pops the top item off of this stack and return it.
 public Object push(Object item) 
    Pushes a new item onto the top of this stack. The pushed item is also returned. This is equivalent to calling add.
 public Object remove() 
    Removes the element on the top of the stack.
 public int search(Object object) 
    Returns the one-based position of the distance from the top that the specified object exists on this stack, where the top-most element is considered to be at distance 1. If the object is not present on the stack, return -1 instead. The equals() method is used to compare to the items in this stack.