Interface MyStack<E>

All Known Implementing Classes:
ArrayStackImpl, LinkedListStackImpl

public interface MyStack<E>
A stack-like interface.

Unfortunately, java.util.Stack uses a Vector, and is, therefore, needlessly synchronized in a non-multi-threaded environment. As a result, it was necessary to re-implement the stack in this manner by using a non-synchronized list.

Author:
Danny Daglas
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Eliminate all items from the stack.
    Inspect the top-most element without affecting the stack.
    pop()
    Pop an item off the stack and return that item to the callee.
    void
    push(E o)
    Push an item onto the stack.
    int
    size.
  • Method Details

    • push

      void push(E o)
      Push an item onto the stack.
      Parameters:
      o - The item to push onto the stack.
    • pop

      E pop()
      Pop an item off the stack and return that item to the callee.
      Returns:
      The top of the stack, which is subsequently removed from the stack.
    • size

      int size()

      size.

      Returns:
      The number of elements within the stack.
    • clear

      void clear()
      Eliminate all items from the stack.
    • peek

      E peek()
      Inspect the top-most element without affecting the stack.
      Returns:
      the top of the stack, without removing it from the stack