Interface StackInterface<T>

All Known Implementing Classes:
StackInfinitePush

public interface StackInterface<T>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes all entries from the stack.
    boolean
    Determines if there are any elements in the stack.
    Get this stack's top entry.
    pop()
    Removes and returns this stack's top entry.
    void
    push(T element)
    Adds a new entry to the top of this stack.
  • Method Details

    • push

      void push(T element)
      Adds a new entry to the top of this stack.
      Parameters:
      element - element to be added to the stack
    • pop

      T pop()
      Removes and returns this stack's top entry. The size of the stack is decreased by one.
      Returns:
      The element at the top of the stack.
      Throws:
      EmptyStackException - if the stack is empty when the method is invoked
    • peek

      T peek()
      Get this stack's top entry. The size of the stack is not changed.
      Returns:
      The element at the top of the stack.
      Throws:
      EmptyStackException - if the stack is empty
    • isEmpty

      boolean isEmpty()
      Determines if there are any elements in the stack.
      Returns:
      True if the stack is empty.
    • clear

      void clear()
      Removes all entries from the stack.