Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Queue<T>

A super simple queue built on an array. The main advantage of using this is that dequeue() never returns undefined, allowing to write type-checked code like this:

const queue = new Queue(1, 2, 3); // type: Queue<number>
while (!queue.isEmpty()) {
  const elem = queue.dequeue(); // type: number
}

Type parameters

  • T

    queue element

Hierarchy

  • Queue

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Queue<T>(...elements: T[]): Queue<T>

Properties

Private queue

queue: T[]

Accessors

isEmpty

  • get isEmpty(): boolean

size

  • get size(): number

Methods

dequeue

  • dequeue(): T

enqueue

  • enqueue(...elements: T[]): void

Generated using TypeDoc