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 value Value and priority Priority.

meth (Queue: pqueue):keep(Target: integer, Value: any, Priority: any): pqueue::entry | nil

Creates and returns a new entry in Queue with value Value and priority Priority if either Queue has fewer than Target entries or Priority is lower than the current highest priority entry in Queue (removing the current highest priority entry in this case).

Returns the entry removed from Queue or nil if no entry was removed.

meth (Queue: pqueue):next: pqueue::entry | nil

Removes and returns the highest priority entry in Queue, or nil if Queue is empty.

meth (Queue: pqueue):peek: pqueue::entry | nil

Returns the highest priority entry in Queue without removing it, or nil if Queue 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 to Priority.

meth (Entry: pqueue::entry):lower(Priority: any): pqueue::entry

Changes the priority of Entry to Priority only if its current priority is greater than Priority. 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 returns nil.

meth (Entry: pqueue::entry):raise(Priority: any): pqueue::entry

Changes the priority of Entry to Priority only if its current priority is less than Priority. 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.