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


6.2 Finite map operations

Function: psq-ref PSQ KEY

Return the priority of KEY if it is in PSQ. If KEY is not in PSQ an assertion violation is raised.

(let* ((Q (make-psq string< <))
       (Q (psq-set Q "salut" 2))
       (Q (psq-set Q "hello" 1))
       (Q (psq-set Q "ciao"  4))
       (Q (psq-set Q "ohayo" 3)))
  (values (psq-ref Q "salut")
          (psq-ref Q "hello")
          (psq-ref Q "ciao")
          (psq-ref Q "ohayo")))
⇒ 2 1 4 3
Function: psq-set PSQ KEY PRIORITY

Return the priority search queue obtained from inserting KEY with a given PRIORITY. If KEY is already in the priority search queue, it updates the priority to the new value.

Function: psq-update PSQ KEY PRIORITY-UPDATE DEFAULT-PRIORITY

Return the priority search queue obtained by modifying the priority of KEY, by the given function PRIORITY-UPDATE. If KEY is not in PSQ: it is inserted with the priority obtained by calling the function PRIORITY-UPDATE on the value DEFAULT-PRIORITY.

PRIORITY-UPDATE must be a procedure accepting a priority value as single argument and returning a priority value as single value.

(let* ((Q  (make-psq string< <))
       (Q  (psq-set Q "salut" 2))
       (P1 (psq-ref Q "salut"))
       (Q  (psq-update Q "salut"
                       (lambda (P) (+ 2 P))
                       0))
       (P2 (psq-ref Q "salut")))
  (values P1 P2))
⇒ 2 4

(let* ((Q  (make-psq string< <))
       (Q  (psq-update Q "salut"
                       (lambda (P) (+ 1 P))
                       9)))
  (psq-ref Q "salut"))
⇒ 10
Function: psq-delete PSQ KEY

Return the priority search queue obtained by removing the KEY/priority association from the PSQ. If KEY is not in the queue: the returned search queue will be the same as the original.

Function: psq-contains? PSQ KEY

Return #t if there is an association for the given KEY in PSQ, #f otherwise.


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

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