sorted-map-has-key?
This commit is contained in:
parent
26bd5c7638
commit
3bfc9b910a
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue