Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

org.openquark.cal.util
Class ArrayStack<E>

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

public class ArrayStack<E>
extends ArrayList<E>

A simple stack implementation based on ArrayList. It is faster for single-threaded use than Stack which is thread-safe.

Author:
Joseph Wong, Bo Ilic
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
protected ArrayStack()
           
 
Method Summary
 boolean empty()
           
static
<E> ArrayStack<E>
make()
           
 E peek()
           
 E peek(int index)
           
 E pop()
           
 void popN(int n)
          Pops n elements off the stack.
 void push(E e)
          Unlike java.util.Stack.push, this method does not return its argument.
 int search(E e)
           
 
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

ArrayStack

protected ArrayStack()
Method Detail

make

public static <E> ArrayStack<E> make()

push

public final void push(E e)
Unlike java.util.Stack.push, this method does not return its argument. This is a small micro-optimization.

Parameters:
e - adds the element 'e' to the top of the stack

pop

public final E pop()
Returns:
returns and removes the top element of the stack
Throws:
EmptyStackException - if the stack is empty

popN

public final void popN(int n)
Pops n elements off the stack.

Parameters:
n - number of elements to pop
Throws:
EmptyStackException - if there are not enough elements to pop

peek

public final E peek()
Returns:
returns the top element of the stack, without removing it
Throws:
EmptyStackException - if the stack is empty

peek

public final E peek(int index)
Parameters:
index - the zero-based index of an element from the top of the stack
Returns:
returns the element at the given index from the top of the stack, without removing it
Throws:
EmptyStackException - if the stack does not have enough elements to satisfy this request.

empty

public final boolean empty()
Returns:
true iff the stack is empty

search

public final int search(E e)
Parameters:
e - element to find. Can be null.
Returns:
the 1-based position of 'e' on the stack, or -1 if 'e' is not on the stack.

Business Objects
Quark Platform Documentation
Version 1.7.0_0
Business Objects

Copyright © 2007 Business Objects. All rights reserved.