annotate src/multimap_fn.sml @ 2203:39faa4a037f4

ML half of initial prototype. (Doesn't compile because there's no C yet.)
author Ziv Scully <ziv@mit.edu>
date Tue, 25 Mar 2014 02:04:06 -0400
parents
children 365727ff68f4
rev   line source
ziv@2203 1 functor MultimapFn (structure KeyMap : ORD_MAP structure ValSet : ORD_SET) = struct
ziv@2203 2 type key = KeyMap.Key.ord_key
ziv@2203 3 type item = ValSet.item
ziv@2203 4 type items = ValSet.set
ziv@2203 5 type multimap = ValSet.set KeyMap.map
ziv@2203 6 fun inserts (kToVs : multimap, k : key, vs : items) : multimap =
ziv@2203 7 KeyMap.unionWith ValSet.union (kToVs, KeyMap.singleton (k, vs))
ziv@2203 8 fun insert (kToVs : multimap, k : key, v : item) : multimap =
ziv@2203 9 inserts (kToVs, k, ValSet.singleton v)
ziv@2203 10 fun find (kToVs : multimap, k : key) =
ziv@2203 11 case KeyMap.find (kToVs, k) of
ziv@2203 12 SOME vs => vs
ziv@2203 13 | NONE => ValSet.empty
ziv@2203 14 end