Class Queue<T>

The Queue class implements the functionality of a queue - more specifically, a FIFO (first-in, first-out) queue.

Type Parameters

  • T

Constructors

Accessors

Methods

Constructors

  • Constructs a new queue, optionally with the specified elements.

    Type Parameters

    • T

    Parameters

    • Rest...elements: T[]

      Elements to add to the queue.

    Returns Queue<T>

Accessors

  • get length(): number
  • Gets the length of the queue.

    Returns number

Methods

  • Returns an iterator that allows iterating over all elements in the queue.

    Returns Generator<T, void, unknown>

  • Removes all entries from this instance.

    Returns void

  • Returns the front (first) element from the queue. If the queue is empty, undefined is returned and the queue is not modified.

    Returns T

    The front element or undefined if empty.

  • Removes the front (first) element from the queue and returns it. If the queue is empty, undefined is returned and the queue is not modified.

    Returns T

    The front element or undefined if empty.

  • Appends a new element to the end of the queue, and returns the new length of the queue.

    Parameters

    • element: T

    Returns number

  • Converts this instance to a string.

    Returns string