Class LinkedListStackImpl<E>

All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, Deque<E>, List<E>, Queue<E>, MyStack<E>

public class LinkedListStackImpl<E> extends LinkedList<E> implements MyStack<E>
A simple delegate to a LinkedList. Unlike java.util.Stack, this implementation is non-synchronized to improve performance.

It performs slower than the ArrayStackImpl version.

There is no maximum capacity which is enforced, nor is there any checks if pop() is executed on an empty stack.

Author:
Danny Daglas
See Also:
  • Constructor Details

    • LinkedListStackImpl

      public LinkedListStackImpl()
  • Method Details

    • push

      public void push(E o)
      Push an item onto the stack.
      Specified by:
      push in interface Deque<E>
      Specified by:
      push in interface MyStack<E>
      Overrides:
      push in class LinkedList<E>
      Parameters:
      o - The item to push onto the stack.
    • pop

      public E pop()
      Pop an item off the stack and return that item to the callee.
      Specified by:
      pop in interface Deque<E>
      Specified by:
      pop in interface MyStack<E>
      Overrides:
      pop in class LinkedList<E>
      Returns:
      The top of the stack, which is subsequently removed from the stack.