priqueue
priority queue functions
Calling Sequence
Parameters
Description
Examples
priqueue:-initialize(pq)
priqueue:-insert(NewRecord, pq)
priqueue:-extract(pq)
pq
-
name of the priority queue
NewRecord
structure to be inserted in the queue
The initialize function makes the necessary assignments (side effects) so that the queue pq is initialized with an empty queue. The queue pq is treated as an unbounded array of the inserted records. Additionally, pq0 maintains the number of entries in the queue.
The insert function adds an element to the queue. The queue is a maximum queue, that is, the maximum element is kept on the head of the queue. The criteria for ordering the queue is giving by NewRecord1 and hence this value should exist and be comparable.
The extract function returns the stored record with the highest value (in its first position) and deletes this record from the queue.
Multiple priority queues are allowed.
If inspection alone is desired, the maximum element of the queue is always at pq1.
To use a priqueue function, either define that specific function alone by the command with(priqueue,function), or define all priqueue functions by the command with(priqueue).
with⁡priqueue:
initialize⁡DailyTemps
0
insert⁡14,Apr30,DailyTemps
insert⁡24,May4,DailyTemps
extract⁡DailyTemps
24,May4
14,Apr30
See Also
DEQueue
heap
Download Help Document