Add sorted-map-keys

This commit is contained in:
Tony Garnock-Jones 2014-07-18 11:31:55 -07:00
parent 0b0020153e
commit a5dc977d73
1 changed files with 12 additions and 1 deletions

View File

@ -17,10 +17,13 @@
sorted-map-get
sorted-map-size
sorted-map-max
sorted-map-delete)
sorted-map-delete
sorted-map-keys
)
(require "canonicalize.rkt")
(require "memoize.rkt")
(require racket/set)
; A purely functional sorted-map library.
@ -445,3 +448,11 @@
; Delete the key, and color the new root black:
(blacken (del node)))
;; 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))
(match node
[(T! l k v r) (walk l (set-add (walk r acc) k))]
[(L _) acc])))