Next: , Previous: , Up: Top   [Contents][Index]


6 Priority search queues

Priority search queues are a combination of two common abstract data types: finite maps, and priority queues. As such, it provides for access, insertion, removal and update on arbitrary keys, as well as for easy removal of the element with the lowest priority.

Where a procedure takes a key or priority these are expected to be compatible with the relevant ordering procedures on the <psq>.

(let* ((Q (make-psq string< <))
       (Q (psq-set Q "salut" 2))
       (Q (psq-set Q "hello" 1))
       (Q (psq-set Q "ciao"  1))
       (Q (psq-set Q "ohayo" 2)))
  (receive (key1 Q1)
      (psq-pop Q)
    (receive (key2 Q2)
        (psq-pop Q1)
      (receive (key3 Q3)
          (psq-pop Q2)
        (receive (key4 Q4)
            (psq-pop Q3)
          (values key1 key2 key3 key4))))))
⇒ "ciao" "hello" "ohayo" "salut"

Next: , Previous: , Up: Top   [Contents][Index]

This document describes version 0.5.0-devel.1 of MMCK PFDS.