* Removes and returns the next queued tuple, rebuilding the iterator when * the underlying tuple set has changed since the last full pass. * @returns {[T, V, ...EXPECTED_ANY] | undefined} The head of the queue of `undefined` if this queue is empty.
()
| 54 | * @returns {[T, V, ...EXPECTED_ANY] | undefined} The head of the queue of `undefined` if this queue is empty. |
| 55 | */ |
| 56 | dequeue() { |
| 57 | const result = this._iterator.next(); |
| 58 | if (result.done) { |
| 59 | if (this._set.size > 0) { |
| 60 | this._iterator = this._set[Symbol.iterator](); |
| 61 | const value = |
| 62 | /** @type {[T, V, ...EXPECTED_ANY]} */ |
| 63 | (this._iterator.next().value); |
| 64 | this._set.delete(...value); |
| 65 | return value; |
| 66 | } |
| 67 | return; |
| 68 | } |
| 69 | this._set.delete(.../** @type {[T, V, ...EXPECTED_ANY]} */ (result.value)); |
| 70 | return result.value; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | module.exports = TupleQueue; |