pqueue.icn: Procedures for manipulating priority queues

procedure pq:              create priority queue
procedure pqget:           remove first priority queue element
procedure pqgen:           generate priority queue elements
procedure pqput:           insert priority queue element

link pqueue
May 3, 2001; William S. Evans and Gregg M. Townsend
This file is in the public domain.

These procedures manipulate priority queues.

pq(L)           returns a priority queue containing the elements
                in L.  L is a list (or table or set) of pqelem
                records, each containing a data and priority field.
                If L is &null, pq() returns an empty priority queue.

pqget(Q)        returns and removes the highest priority element
                from Q.  Q is a priority queue returned by pq().

pqput(Q, e)     adds element e (a pqelem record) to Q.

pqgen(Q)        generates the elements in Q in priority order.

pqelem(d, p)    constructs a record with data d and priority p.
____________________________________________________________

Priority queues are implemented as heaps.  Heaps are
implemented as lists in the usual fashion.

Source code | Program Library Page | Icon Home Page