| | |
| | | "use strict"; |
| | | |
| | | /** |
| | | * FIFO queue backed by arrays with a reversed dequeue buffer to avoid the cost |
| | | * of repeated `Array#shift` operations. |
| | | * @template T |
| | | */ |
| | | class ArrayQueue { |
| | | /** |
| | | * Seeds the queue with an optional iterable of items in dequeue order. |
| | | * @param {Iterable<T>=} items The initial elements. |
| | | */ |
| | | constructor(items) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the number of elements in this queue. |
| | | * Returns the current number of items waiting in either internal buffer. |
| | | * @returns {number} The number of elements in this queue. |
| | | */ |
| | | get length() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Empties the queue. |
| | | * Removes all pending items from both internal buffers. |
| | | */ |
| | | clear() { |
| | | this._list.length = 0; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Appends the specified element to this queue. |
| | | * Appends an item to the tail of the queue. |
| | | * @param {T} item The element to add. |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Retrieves and removes the head of this queue. |
| | | * Removes and returns the next item in FIFO order, switching to a reversed |
| | | * buffer when that is cheaper than shifting from the front of the array. |
| | | * @returns {T | undefined} The head of the queue of `undefined` if this queue is empty. |
| | | */ |
| | | dequeue() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Finds and removes an item |
| | | * Removes the first matching item from whichever internal buffer currently |
| | | * contains it. |
| | | * @param {T} item the item |
| | | * @returns {void} |
| | | */ |