Package org.sentrysoftware.jawk.util
Class ArrayStackImpl<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
org.sentrysoftware.jawk.util.ArrayStackImpl<E>
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<E>
,Collection<E>
,List<E>
,RandomAccess
,MyStack<E>
A stack implemented with an ArrayList.
Unlike the
java.util.Stack
which uses a
java.util.Vector
as a storage mechanism,
this implementation is non-synchronized to improve performance.
It performs quicker than the LinkedListStackImpl
version.
There is no maximum capacity which is enforced, nor is there any
checks if pop()
is executed on an empty stack.
- Author:
- Danny Daglas
- See Also:
-
Constructor Summary
-
Method Summary
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
Methods inherited from class java.util.AbstractList
equals, hashCode
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from interface java.util.Collection
parallelStream, stream
Methods inherited from interface java.util.List
containsAll, equals, hashCode
-
Constructor Details
-
ArrayStackImpl
public ArrayStackImpl()Allocates an ArrayList with a capacity of 100.
-
-
Method Details
-
push
Push an item onto the stack. Push an item to the stack. -
pop
Pop an item off the stack and return that item to the callee. Pops an item off the stack.Warning: no checks are done in terms of size, etc. If a
pop()
is called on an empty stack, anArrayIndexOutOfBoundException
is thrown. -
peek
Inspect the top-most element without affecting the stack.
-