Package com.tangosol.util
Class SimpleStack
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList
-
- com.tangosol.util.SimpleStack
-
- All Implemented Interfaces:
Serializable,Cloneable,Iterable,Collection,List,RandomAccess
public class SimpleStack extends ArrayList
A LIFO (last in, first out) unbounded stack of objects. A SimpleStack supports the following operations:adda new element to the top of the stackremoveand return the element on the top of the stackreturnthe element on the top of the stack
Stackexcept that it extendsArrayListrather thanVectorand is therefore not thread safe. The top of the stack corresponds to the last element in the underlying list, whereas the bottom corresponds to the first.The SimpleStack implementation supports null elements; however, if null elements are added, care must be taken to distinguish a null element returned from
pop()orpeek()from a null value that indicates the stack is empty.- Since:
- Coherence 3.2
- Author:
- jh 2006.05.04
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Constructor Summary
Constructors Constructor Description SimpleStack()Create a new empty SimpleStack.SimpleStack(int nCapacity)Create a new empty SimpleStack with the specified initial capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectpeek()Return the object that is currently on top of the stack.Objectpop()Remove and return the object that is currently on top of the stack.voidpush(Object oElement)Add the given object to the top of the stack.-
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
-
Methods inherited from class java.util.AbstractCollection
containsAll, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
containsAll
-
-
-
-
Method Detail
-
push
public void push(Object oElement)
Add the given object to the top of the stack.- Parameters:
oElement- the object to place on top of the stack
-
pop
public Object pop()
Remove and return the object that is currently on top of the stack.- Returns:
- the object removed from the top of the stack or null if the stack is empty
-
peek
public Object peek()
Return the object that is currently on top of the stack.- Returns:
- the object on top of the stack or null if the stack is empty
-
-