Removes an item from the queue and return its value. Time complexity: O(1).
The value stored in item.
Adds an item to the end of the queue. Time complexity: O(1).
Returns the item at front of the queue without dequeuing. Time complexity: O(1).
The value stored in the item.
Returns the current size of the queue. Time complexity: O(1).
Size of the queue.
Generated using TypeDoc
The queue data structure allows you to perform FIFO operations in constant time. You can enqueue, dequeue and peek an item, and get the size of the queue. JavaScript arrays have 'shift' and 'push' methods but 'shift' take O(n) time.