Class SLListQueue<T>

Singly linked list queue -- an implementation of the Queue ADT using a singly, circularly linked list with a dummy header node whose successor is the tail node (last queue element) when the queue is not empty.

Implements

Type Parameters

  • T

    The type of all elements in the queue.

Hierarchy

  • SLListQueue

Implements

Constructors

Properties

Accessors

Methods

Constructors

Properties

#header: Node<T>

Dummy header node whose successor is the tail node that stores the last queue element when the queue is not empty.

#numElems: number

Number of elements in the queue.

Accessors

  • get size(): number
  • Number of elements in the queue.

    Returns number

Methods

  • Gets the head node of the underlying linked list.

    Returns

    Head node if the queue is not empty, null otherwise.

    Returns null | Node<T>

  • Gets the tail node of the underlying linked list.

    Returns

    Tail node if the queue is not empty, null otherwise.

    Returns null | Node<T>

  • Removes the front element from the queue if not empty.

    Returns

    true on success, false otherwise.

    Returns boolean

  • Whether the queue has no elements.

    Returns

    true if the queue is empty, false otherwise.

    Returns boolean

  • Adds an element to the end of the queue.

    Parameters

    • elem: T

      The element to be added.

    Returns void

  • Gets the element at the front of the queue if not empty.

    Returns

    The front element.

    Returns null | T

  • Iterates over all elements of this queue from the front.

    The given operation will be performed on each element iterated.

    Parameters

    • action: ((elem: T) => void)

      The operation to be performed on each element.

        • (elem: T): void
        • Parameters

          • elem: T

          Returns void

    Returns void

  • Creates a string representation of this queue.

    Elements are presented in the queue order from left to right.

    Returns

    The string representation.

    Parameters

    • separator: string = ' '

      Element separator. Defaults to a single space character.

    Returns string

Generated using TypeDoc