Class CircularQueue<T>

A circular queue data structure.

Type Parameters

  • T

    The type of elements held in the queue.

Hierarchy

Constructors

Properties

Accessors

Methods

Constructors

Properties

_data: T[] = []
_head: number = 0
_tail: number = 0
size: number = 0

The number of elements in the list.

Accessors

  • get hasRoom(): boolean
  • Returns true if the queue has available space.

    Returns boolean

    True if the queue has available space, false otherwise.

  • get items(): readonly T[]
  • Returns an array of all elements in the queue.

    Returns readonly T[]

    An array of all elements in the queue or an empty array if the queue is empty.

Methods

  • Adds an element to the end of the queue.

    Parameters

    • element: T

      The element to add to the queue.

    Returns void

    Throws

    An error if the queue is full.

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

    Returns undefined | T

    The element at the front of the queue or undefined if the queue is empty.