A queue is a data structure that follows the FIFO (first in, first out) principle.

Type Parameters

  • T

Constructors

Accessors

Methods

Constructors

  • Type Parameters

    • T

    Parameters

    • OptionalinitialData: T[]

    Returns Queue<T>

Accessors

  • get length(): number

    Returns number

Methods

  • Clears the queue

    Returns void

  • Removes the first item in the queue and returns it

    Returns undefined | T

    The first item in the queue

  • Adds an item to the end of the queue

    Parameters

    • item: T

      The item to add to the queue

    Returns void

  • Returns boolean

  • Retrieves the first item in the queue without removing it

    Returns undefined | T

    The first item in the queue

  • Removes an item from the queue

    Parameters

    • item: T

      The item to remove from the queue

    Returns undefined | T