Queue

A queue is a first in first out (FIFO) data structure.

Implementation

Trivial, just use a JavaScript array push/shift methods. Or if you want to encapsulate it in a class:

class Queue<T> {
  _store: T[] = [];
  push(val: T) {
    this._store.push(val);
  }
  pop(): T | undefined {
    return this._store.shift();
  }
}

results matching ""

    No results matching ""