Persistent priority queue implemented with pairing heap. Implementation allows fast peek, enqueue, dequeue.
Creates new queue. By default uses comparator
for minimal heap, i.e. item with
the smallest priority will dequeue first. If arraylike
is passed populate queue
Property returning size of the queue
Yields true
if length
is zero and false
otherwise
Enqueues element
into the queue with specified priority
. Returns new queue
Dequeue element from queue and returns new queue. If queue is empty returns itself
Returns element with the highest priority or undefined
if the queue is empty
Returns highest priority of the queue or undefined
if the queue is empty
Returns true
if the element
is in the queue and false
otherwise.
This is slow O(n) method
If queue has items returns new empty queue otherwise returns itself
Calls callback
for each element and priority in the queue.