Class Queue3<T>

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

public class Queue3<T> extends QueueSecondary<T>
Queue represented as a Sequence of entries, with implementations of primary methods.
Abstraction Relation (interpretation mapping between $this and this):
this = $this.entries
  • Constructor Details

    • Queue3

      public Queue3()
      No-argument constructor.
  • Method Details

    • newInstance

      public final Queue<T> newInstance()
      Description copied from interface: Standard
      Returns a new object with the same dynamic type as this, having an initial value. If the type T has a no-argument constructor, then the value of the new returned object satisfies the contract of the no-argument constructor for T. If T does not have a no-argument constructor, then the value of the new returned object satisfies the contract of the constructor call that was used to initialize this .
      Returns:
      new object "like" this with an initial value
    • clear

      public final void clear()
      Description copied from interface: Standard
      Resets this to an initial value. If the type T has a no-argument constructor, then this satisfies the contract of the no-argument constructor for T. If T does not have a no-argument constructor, then this satisfies the contract of the constructor call that was used to initialize #this.
    • transferFrom

      public final void transferFrom(Queue<T> source)
      Description copied from interface: Standard
      Sets this to the incoming value of source, and resets source to an initial value; the declaration notwithstanding, the dynamic type of source must be the same as the dynamic type of this. If the type T has a no-argument constructor, then source satisfies the contract of the no-argument constructor for T. If T does not have a no-argument constructor, then source satisfies the contract of the constructor call that was used to initialize #source.
      Parameters:
      source - object whose value is to be transferred
    • enqueue

      public final void enqueue(T x)
      Description copied from interface: QueueKernel
      Adds x to the end of this.
      Parameters:
      x - the entry to be added
    • dequeue

      public final T dequeue()
      Description copied from interface: QueueKernel
      Removes and returns the entry at the front of this.
      Returns:
      the entry removed
    • length

      public final int length()
      Description copied from interface: QueueKernel
      Reports length of this.
      Returns:
      the length of this
    • iterator

      public final Iterator<T> iterator()
    • replaceFront

      public final 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>
      Overrides:
      replaceFront in class QueueSecondary<T>
      Parameters:
      x - the new front entry
      Returns:
      the old front entry