pqueue¶
type pqueue < sequenceA priority queue with values and associated priorities. The priority comparison function
Fnis supplied at construction, defaulting to>. If(Valueᵢ, Priorityⱼ)and(Valueᵢ, Priorityⱼ)are added to the queue withFn(Priorityᵢ, Priorityⱼ), thenValueᵢwill come beforeValueⱼwhen taking entries from the queue.meth pqueue(Fn: function): pqueueIf
(Valueᵢ, Priorityⱼ)and(Valueᵢ, Priorityⱼ)are added to the queue withFn(Priorityᵢ, Priorityⱼ), thenValueᵢwill come beforeValueⱼwhen taking entries from the queue. Returns a new priority queue usingFnto compare priorities.meth pqueue(): pqueueReturns a new priority queue using
>to compare priorities.meth (Queue: pqueue):count: integerReturns the number of entries in
Queue.meth (Queue: pqueue):entry(Value: any, Priority: any): pqueue::entryCreates and returns a new entry with value
Valueand priorityPrioritywithout inserting it intoQueue.meth (Queue: pqueue):insert(Value: any, Priority: any): pqueue::entryCreates and returns a new entry in
Queuewith valueValueand priorityPriority.meth (Queue: pqueue):keep(Target: integer, Value: any, Priority: any): pqueue::entry | nilCreates and returns a new entry in
Queuewith valueValueand priorityPriorityif eitherQueuehas fewer thanTargetentries orPriorityis lower than the current highest priority entry inQueue(removing the current highest priority entry in this case).Returns the entry removed from
Queueornilif no entry was removed.meth (Queue: pqueue):next: pqueue::entry | nilRemoves and returns the highest priority entry in
Queue, ornilifQueueis empty.meth (Queue: pqueue):peek: pqueue::entry | nilReturns the highest priority entry in
Queuewithout removing it, ornilifQueueis empty.type pqueue::entryA entry in a priority queue.
meth (Entry: pqueue::entry):adjust(Priority: any): pqueue::entryChanges the priority of
EntrytoPriority.meth (Entry: pqueue::entry):lower(Priority: any): pqueue::entryChanges the priority of
EntrytoPriorityonly if its current priority is greater thanPriority.Entryis added back into its queue if the priority changes.meth (Entry: pqueue::entry):priority: anyReturns the priority associated with
Entry.meth (Entry: pqueue::entry):queued: pqueue::entry | nilReturns
Entryif it is currently in the priority queue, otherwise returnsnil.meth (Entry: pqueue::entry):raise(Priority: any): pqueue::entryChanges the priority of
EntrytoPriorityonly if its current priority is less thanPriority.Entryis added back into its queue if the priority changes.meth (Entry: pqueue::entry):remove: pqueue::entryRemoves
Entryfrom its priority queue.meth (Entry: pqueue::entry):requeue: pqueue::entryAdds
Entryback into its priority queue if it is not currently in the queue.meth (Entry: pqueue::entry):value: anyReturns the value associated with
Entry.