sorted-map-has-key?

This commit is contained in:
Tony Garnock-Jones 2014-07-18 18:18:18 -07:00
parent 26bd5c7638
commit 3bfc9b910a
1 changed files with 12 additions and 0 deletions

View File

@ -18,6 +18,7 @@
sorted-map-size
sorted-map-max
sorted-map-delete
sorted-map-has-key?
sorted-map-keys
sorted-map-values
)
@ -451,6 +452,17 @@
(blacken (del node)))
;; tonyg 20140718 True iff key is in node
(define (sorted-map-has-key? node key)
(let walk ((node node))
(match node
[(L!) #f]
[(T cmp c l k v r)
(switch-compare (cmp key k)
[< (walk l)]
[= #t]
[> (walk r)])])))
;; tonyg 20140718 Retrieve a set of the keys of smap
(define (sorted-map-keys smap [empty-set (set)])
(let walk ((node smap) (acc empty-set))