Interface Stack<T>

  • All Known Implementing Classes:
    ArrayListStack

    public interface Stack<T>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear()  
      boolean empty()
      Tests if stack is empty.
      T peek()
      Returns item from the top of the stack.
      T pop()
      Removes and returns item from the top of the stack.
      T push​(T x)
      Adds an item to the top of the stack.
      int size()
      Returns the size of the stack.
    • Method Detail

      • push

        T push​(T x)
        Adds an item to the top of the stack.
        Parameters:
        x - the item to add.
        Returns:
        the item added.
      • pop

        T pop()
        Removes and returns item from the top of the stack.
        Returns:
        the former top item.
        Throws:
        java.util.EmptyStackException - if stack is empty.
      • peek

        T peek()
        Returns item from the top of the stack.
        Returns:
        the top item.
        Throws:
        java.util.EmptyStackException - if stack is empty.
      • empty

        boolean empty()
        Tests if stack is empty.
        Returns:
        true if the stack is empty; false otherwise.
      • size

        int size()
        Returns the size of the stack.
        Returns:
        the size of the stack.
      • clear

        void clear()