A First-In-First-Out (FIFO) queue data structure.

Typeparam

T - The type of elements stored in the queue

Type Parameters

  • T

Constructors

Properties

Methods

Constructors

Properties

back: SingleNode<T> = null
front: SingleNode<T> = null

Methods

  • Removes and returns the element from the front of the queue.

    Returns void

    Throws

    Error if the queue is empty

  • Adds an element to the back of the queue.

    Parameters

    • val: T

      The value to add

    Returns void

  • Checks if the queue is empty.

    Returns boolean

    True if the queue contains no elements, false otherwise

  • Returns the element at the front of the queue without removing it.

    Returns T

    The element at the front of the queue

    Throws

    Error if the queue is empty

  • Returns the number of elements in the queue.

    Returns number

    The size of the queue