Class StackSecondary<T>

java.lang.Object
components.stack.StackSecondary<T>
Type Parameters:
T - type of Stack entries
All Implemented Interfaces:
Stack<T>, StackKernel<T>, Standard<Stack<T>>, Iterable<T>
Direct Known Subclasses:
Stack1L, Stack2, Stack3

public abstract class StackSecondary<T> extends Object implements Stack<T>
Layered implementations of secondary methods for Stack.

Execution-time performance of flip implemented in this class is O(| this|).

  • Constructor Details

  • Method Details

    • equals

      public final boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • top

      public T top()
      Description copied from interface: Stack
      Reports the top of this.
      Specified by:
      top in interface Stack<T>
      Returns:
      the top entry of this
    • replaceTop

      public T replaceTop(T x)
      Description copied from interface: Stack
      Replaces the top of this with x, and returns the old top.
      Specified by:
      replaceTop in interface Stack<T>
      Parameters:
      x - the new top entry
      Returns:
      the old top entry
    • flip

      public void flip()
      Description copied from interface: Stack
      Reverses ("flips") this.
      Specified by:
      flip in interface Stack<T>