hackerbase/src/util-bst-bdict.scm

45 lines
716 B
Scheme

(declare (unit util-bst-bdict))
(import duck)
(module*
util-bst-bdict
#:doc ("Reimplementation of old number-only BST dictionary.")
(
list->bdict
bdict-find-value
bdict-ref
bdict-filter-values
bdict-keys
bdict-map-list
bdict-map-dict
bdict-update
)
(import scheme
util-bst)
(define (list->bdict lst)
(list->bst lst 'fixnum eq? <))
(define (bdict-find-value d p?)
(let ((kv (bst-find-pair d p?)))
(if kv
(cdr kv)
#f)))
(define bdict-ref bst-ref)
(define (bdict-filter-values d p?)
(map cdr (bst-filter-pairs d p?)))
(define bdict-keys bst-keys)
(define bdict-map-list bst-map-list)
(define bdict-map-dict bst-map-bst)
(define bdict-update bst-update)
)