Creates a new queue.
Time complexity: O(n) with initial values, or O(1) without them.
Optionalvalues: Iterable<T, any, any>Optionaloptions: QueueOptionsThe first (next) value in the queue, or undefined when the queue is empty.
Time complexity: O(1).
Whether the queue is empty.
Time complexity: O(1).
The last value in the queue, or undefined when the queue is empty.
Time complexity: O(1).
The number of values in the queue.
Time complexity: O(1).
Returns an iterator over the values in the queue from first to last.
Time complexity: O(1) to create the iterator, and O(n) for a full iteration.
Returns the value at the given index without removing it.
Negative indexes count backwards from the end of the queue.
Time complexity: O(1).
Removes all values from the queue.
Time complexity: O(1).
Deletes values from the queue starting at start and ending before end.
When end is omitted, only the value at start is deleted.
Negative indexes count backwards from the end of the queue.
Returns the number of deleted values.
Time complexity: O(k) when deleting from either end, where k is the number of deleted values,
and O(n) when deleting from the middle.
Optionalend: numberReturns an iterator over index-value pairs in the queue.
Time complexity: O(n) for a full iteration and O(1) per value.
Returns the index of the first occurrence of a value in the queue, or -1 when it is not found.
Time complexity: O(n).
Returns the index of the last occurrence of a value in the queue, or -1 when it is not found.
Time complexity: O(n).
OptionalfromIndex: numberAdds a value to the end of the queue.
Time complexity: O(1) amortized.
Removes and returns the first (next) value in the queue.
Returns undefined when the queue is empty.
Time complexity: O(1) amortized, with occasional O(n) compaction.
Returns the queue values as a new array.
Time complexity: O(n).
Returns an iterator over the values in the queue from first to last.
Time complexity: O(n) for a full iteration and O(1) per value.
An efficient queue implementation that allows you to enqueue and dequeue items in
O(1)time complexity.