Queue (API documentation of hlt.language packages)
Date: 2013-01-30

hlt.language.util

## Class Queue

- java.lang.Object
- - hlt.language.util.Queue

-     public class Queue
      extends java.lang.Object

  This class provides the facilities for a FIFO sequence of objects. It implements the same operation as a stack; namely `push`, `pop`, `peek`, and `isEmpty`. It also provides `enqueue` as a synonym of `push`, and `dequeue` as a synonym of `pop`. In addition, it defines the methods `rush` and `chop` to place an element at the front of the queue and remove (and return) the newest element in the queue (respectively).
  Version:
    Last modified on Tue Jun 19 17:38:00 2012 by hak
  Author:
    Hassan Aït-Kaci
  Copyright:
    © Hassan Aït-Kaci

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Queue()` Constructs an empty queue.
    `Queue(java.util.Collection objects)` Constructs a queue containing the given collection of objects.
    `Queue(java.lang.Object object)` Constructs a queue containing the given object.
    `Queue(java.lang.Object[] objects)` Constructs a queue containing the given array of objects such that the lowest index is the oldest in the queue.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `chop()` Removes and returns the newest object queued in this queue.
    `java.lang.Object` | `dequeue()` Removes and returns the oldest object queued in this queue.
    `void` | `enqueue(java.lang.Object object)` Enqueues the given object in this queue.
    `boolean` | `isEmpty()` Returns `true` iff this queue is empty.
    `java.util.Iterator` | `iterator()` Returns an iterator for this queue in "popping" order; i.e., from the oldest to the newest elelemnt.
    `java.lang.Object` | `peek()` Returns the oldest object queued in this queue without removing it.
    `java.lang.Object` | `pop()` Removes and returns the oldest object queued in this queue.
    `void` | `push(java.lang.Object object)` Enqueues the given object into this queue.
    `Queue` | `reverse()` Returns this queue after reversing it in situ.
    `void` | `rush(java.lang.Object object)` Places the given object at the head of this queue.
    `int` | `size()` Returns the current number of elements in this queue.
    `java.lang.String` | `toString()` Returns a string representation of this queue.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Queue

          public Queue()

      Constructs an empty queue.

    - #### Queue

          public Queue(java.lang.Object object)

      Constructs a queue containing the given object.

    - #### Queue

          public Queue(java.lang.Object[] objects)

      Constructs a queue containing the given array of objects such that the lowest index is the oldest in the queue.

    - #### Queue

          public Queue(java.util.Collection objects)

      Constructs a queue containing the given collection of objects. No guarantee is provided as for the order of enqueuing.

  - ### Method Detail

    - #### isEmpty

          public final boolean isEmpty()

      Returns `true` iff this queue is empty.

    - #### size

          public final int size()

      Returns the current number of elements in this queue.

    - #### enqueue

          public final void enqueue(java.lang.Object object)

      Enqueues the given object in this queue.

    - #### push

          public final void push(java.lang.Object object)

      Enqueues the given object into this queue.

    - #### rush

          public final void rush(java.lang.Object object)

      Places the given object at the head of this queue.

    - #### dequeue

          public final java.lang.Object dequeue()

      Removes and returns the oldest object queued in this queue.

    - #### pop

          public final java.lang.Object pop()

      Removes and returns the oldest object queued in this queue.

    - #### chop

          public final java.lang.Object chop()

      Removes and returns the newest object queued in this queue.

    - #### iterator

          public final java.util.Iterator iterator()

      Returns an iterator for this queue in "popping" order; i.e., from the oldest to the newest elelemnt.

    - #### peek

          public final java.lang.Object peek()

      Returns the oldest object queued in this queue without removing it.

    - #### reverse

          public final Queue reverse()

      Returns this queue after reversing it in situ.

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this queue. It is of the form:

          >> newest ... oldest >>

      Overrides:
        `toString` in class `java.lang.Object`