Package soot.util
Class FastStack<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<T>
-
- soot.util.FastStack<T>
-
- Type Parameters:
T- The elements of the stack
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<T>,Collection<T>,List<T>,RandomAccess
public class FastStack<T> extends ArrayList<T>
A fast, but simple stack implementation. Sadly, java's own stack implementation synchronizes and as such is a bit slower. Note that this implementation does not perform error checking, however, the original implementation would also have thrown an exception in case this implementation throws an exception. It's just that the exception text differs.- Author:
- Marc Miltenberger
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanempty()Returns true if and only if the stack is emptyTpeek()Returns the last item on the stack or throws an exception of there is none.Tpop()Returns and removes the last item from the stack.voidpush(T t)Pushes an item onto 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
-
peek
public T peek()
Returns the last item on the stack or throws an exception of there is none.- Returns:
- the last item on the stack
-
push
public void push(T t)
Pushes an item onto the stack- Parameters:
t- the item
-
pop
public T pop()
Returns and removes the last item from the stack. Throws an exception of there is none.- Returns:
- the last item on the stack, which got pop-ed.
-
empty
public boolean empty()
Returns true if and only if the stack is empty- Returns:
- true if and only if the stack is empty
-
-