Returns an iterator over the queue.
Clears all items and resets the insertion counter.
Returns true if the queue is empty.
Returns the next item to be dequeued without removing it.
Removes and returns the highest-priority item. Returns null if the queue is empty.
Time Complexity: O(log n) Space Complexity: O(1)
Removes and returns many items from the queue. Returns an empty array if the queue is empty.
Adds a new item into the queue.
The payload associated with the item
Numeric priority (lower = higher priority)
Time Complexity: O(log n) Space Complexity: O(1)
Returns the number of items in the queue.
Returns a sorted array of the queue.
A pure data structure that maintains a set of ordered items by numeric priority. Lower priority numbers dequeue first. Ties are broken by insertion order.
Time Complexity:
Space Complexity: O(n) where n is the number of items in the queue