Package soot.util

Class 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
    • Constructor Detail

      • FastStack

        public FastStack()
        Creates a new stack
      • FastStack

        public FastStack​(int initialSize)
        Creates a new stack with the given initial size
        Parameters:
        initialSize - the initial size
    • 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