wicket.util.collections
Class ArrayListStack

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

public final class ArrayListStack
extends java.util.ArrayList

A faster, smaller stack implementation. ArrayListStack is final and unsynchronized (the JDK's methods are synchronized). In addition you can set the initial capacity if you want via the ArrayListStack(int) constructor.

Author:
Jonathan Locke
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArrayListStack()
          Construct.
ArrayListStack(java.util.Collection collection)
          Construct.
ArrayListStack(int initialCapacity)
          Construct.
 
Method Summary
 boolean empty()
          Tests if this stack is empty.
 java.lang.Object peek()
          Looks at the object at the top of this stack without removing it.
 java.lang.Object pop()
          Removes the object at the top of this stack and returns that object.
 void push(java.lang.Object item)
          Pushes an item onto the top of this stack.
 int search(java.lang.Object o)
          Returns the 1-based position where an object is on this 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

ArrayListStack

public ArrayListStack(int initialCapacity)
Construct.

Parameters:
initialCapacity - Initial capacity of the stack

ArrayListStack

public ArrayListStack()
Construct.


ArrayListStack

public ArrayListStack(java.util.Collection collection)
Construct.

Parameters:
collection - The collection to add
Method Detail

push

public final void push(java.lang.Object item)
Pushes an item onto the top of this stack.

Parameters:
item - the item to be pushed onto this stack.

pop

public final java.lang.Object pop()
Removes the object at the top of this stack and returns that object.

Returns:
The object at the top of this stack
Throws:
java.util.EmptyStackException - If this stack is empty.

peek

public final java.lang.Object peek()
Looks at the object at the top of this stack without removing it.

Returns:
The object at the top of this stack
Throws:
java.util.EmptyStackException - If this stack is empty.

empty

public final boolean empty()
Tests if this stack is empty.

Returns:
true if and only if this stack contains no items; false otherwise.

search

public final int search(java.lang.Object o)
Returns the 1-based position where an object is on this stack. If the object o occurs as an item in this stack, this method returns the distance from the top of the stack of the occurrence nearest the top of the stack; the topmost item on the stack is considered to be at distance 1. The equals method is used to compare o to the items in this stack.

Parameters:
o - the desired object.
Returns:
the 1-based position from the top of the stack where the object is located; the return value -1 indicates that the object is not on the stack.


Copyright © 2004-2007 Wicket developers. All Rights Reserved.