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


10.4 Setters and getters

Function: bbtree-ref BBTREE KEY
Function: bbtree-ref BBTREE KEY default

Return the value associated with the KEY in the BBTREE. If the value is not in the tree, then, if the optional third argument is passed, it is returned, otherwise raise a condition with kind pfds-assertion-violation.

Function: bbtree-set BBTREE KEY new-value

Return a new bbtree with KEY associated to new-value. If the KEY is already in BBTREE, its associated value is replaced with the new new-value in the returned bbtree.

Function: bbtree-update BBTREE KEY proc default

Return a new bbtree with the value associated to KEY updated according to the update procedure proc. If KEY was not already in BBTREE, the update procedure is applied to default, and KEY is associated to the resulting value.

The update procedure proc must accept a single argument, being the old value, and return a single value, being the new value.

(let* ((bb1   (alist->bbtree '(("foo" . 10)
                               ("bar" . 12))
                             string<?))
       (dflt  0)
       (bb2   (bbtree-update bb1 "foo" add1 dflt)))
  (bbtree->alist bb2))
⇒ (("bar" . 12) ("foo" . 11))

(let* ((bb1  (alist->bbtree '(("foo" . 10)
                              ("bar" . 12))
                            string<?))
       (dflt 0)
       (bb2  (bbtree-update bb "baz" add1 dflt)))
  (bbtree->alist bb2))
⇒ (("bar" . 12) ("baz" . 1) ("foo" . 10))
Function: bbtree-delete BBTREE KEY

Return a new bbtree with the KEY and its associated value removed. If KEY is not in BBTREE: the returned bbtree is a copy of the original.


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

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