| | |
| | | "use strict"; |
| | | |
| | | /** |
| | | * FIFO queue that keeps items unique by storing them in insertion order inside |
| | | * a `Set`. |
| | | * @template T |
| | | */ |
| | | class Queue { |
| | | /** |
| | | * Seeds the queue with an optional iterable of initial unique items. |
| | | * @param {Iterable<T>=} items The initial elements. |
| | | */ |
| | | constructor(items) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the number of elements in this queue. |
| | | * Returns the number of unique items currently waiting in the queue. |
| | | * @returns {number} The number of elements in this queue. |
| | | */ |
| | | get length() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Appends the specified element to this queue. |
| | | * Enqueues an item, moving nothing if that value is already present. |
| | | * @param {T} item The element to add. |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves and removes the head of this queue. |
| | | * Removes and returns the oldest enqueued item. |
| | | * @returns {T | undefined} The head of the queue of `undefined` if this queue is empty. |
| | | */ |
| | | dequeue() { |