pqueueΒΆ
type pqueue < sequence
A priority queue with values and associated priorities.
meth pqueue(Greater: function): pqueue
Returns a new priority queue using
Greater
to compare priorities.meth pqueue(): pqueue
Returns a new priority queue using
>
to compare priorities.meth (Queue: pqueue):count: integer
Returns the number of entries in
Queue
.meth (Queue: pqueue):insert(Value: any, Priority: any): pqueue::entry
Creates and returns a new entry in
Queue
with valueValue
and priorityPriority
.meth (Queue: pqueue):keep(Target: integer, Value: any, Priority: any): pqueue::entry | nil
Creates and returns a new entry in
Queue
with valueValue
and priorityPriority
if eitherQueue
has fewer thanTarget
entries orPriority
is lower than the current highest priority entry inQueue
(removing the current highest priority entry in this case).Returns the entry removed from
Queue
ornil
if no entry was removed.meth (Queue: pqueue):next: pqueue::entry | nil
Removes and returns the highest priority entry in
Queue
, ornil
ifQueue
is empty.meth (Queue: pqueue):peek: pqueue::entry | nil
Returns the highest priority entry in
Queue
without removing it, ornil
ifQueue
is empty.type pqueue::entry
A entry in a priority queue.
meth (Entry: pqueue::entry):adjust(Priority: any): pqueue::entry
Changes the priority of
Entry
toPriority
.meth (Entry: pqueue::entry):lower(Priority: any): pqueue::entry
Changes the priority of
Entry
toPriority
only if its current priority is greater thanPriority
.Entry
is added back into its queue if the priority changes.meth (Entry: pqueue::entry):priority: any
Returns the priority associated with
Entry
.meth (Entry: pqueue::entry):queued: pqueue::entry | nil
Returns
Entry
if it is currently in the priority queue, otherwise returnsnil
.meth (Entry: pqueue::entry):raise(Priority: any): pqueue::entry
Changes the priority of
Entry
toPriority
only if its current priority is less thanPriority
.Entry
is added back into its queue if the priority changes.meth (Entry: pqueue::entry):remove: pqueue::entry
Removes
Entry
from its priority queue.meth (Entry: pqueue::entry):requeue: pqueue::entry
Adds
Entry
back into its priority queue if it is not currently in the queue.meth (Entry: pqueue::entry):value: any
Returns the value associated with
Entry
.