Class QueueSecondary<T>

java.lang.Object
components.queue.QueueSecondary<T>
Type Parameters:
T - type of Queue entries
All Implemented Interfaces:
Queue<T>, QueueKernel<T>, Standard<Queue<T>>, Iterable<T>
Direct Known Subclasses:
Queue1L, Queue2, Queue3

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

Assuming execution-time performance of O(1) for method iterator and its return value's method next, execution-time performance of front as implemented in this class is O(1). Execution-time performance of replaceFront and flip as implemented in this class is O(|this|). Execution-time performance of append as implemented in this class is O(|q|). Execution-time performance of sort as implemented in this class is O(|this| log |this|) expected, O(|this|^2) worst case. Execution-time performance of rotate as implemented in this class is O(distance mod |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
    • front

      public T front()
      Description copied from interface: Queue
      Reports the front of this.
      Specified by:
      front in interface Queue<T>
      Returns:
      the front entry of this
    • replaceFront

      public T replaceFront(T x)
      Description copied from interface: Queue
      Replaces the front of this with x, and returns the old front.
      Specified by:
      replaceFront in interface Queue<T>
      Parameters:
      x - the new front entry
      Returns:
      the old front entry
    • append

      public void append(Queue<T> q)
      Description copied from interface: Queue
      Concatenates ("appends") q to the end of this.
      Specified by:
      append in interface Queue<T>
      Parameters:
      q - the Queue to be appended to the end of this
    • flip

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

      public void sort(Comparator<T> order)
      Description copied from interface: Queue
      Sorts this according to the ordering provided by the compare method from order.
      Specified by:
      sort in interface Queue<T>
      Parameters:
      order - ordering by which to sort
    • rotate

      public void rotate(int distance)
      Description copied from interface: Queue
      Rotates this.
      Specified by:
      rotate in interface Queue<T>
      Parameters:
      distance - distance by which to rotate