annotate src/multimap_fn.sml @ 2264:bbcf9ba9b39a
Fix another mismatch between expunger SQL generation and SQL parser.
author |
Ziv Scully <ziv@mit.edu> |
date |
Tue, 13 Oct 2015 20:24:37 -0400 |
parents |
365727ff68f4 |
children |
|
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@2213
|
4 type itemSet = ValSet.set
|
ziv@2203
|
5 type multimap = ValSet.set KeyMap.map
|
ziv@2213
|
6 val empty : multimap = KeyMap.empty
|
ziv@2213
|
7 fun insertSet (kToVs : multimap, k : key, vs : itemSet) : multimap =
|
ziv@2203
|
8 KeyMap.unionWith ValSet.union (kToVs, KeyMap.singleton (k, vs))
|
ziv@2203
|
9 fun insert (kToVs : multimap, k : key, v : item) : multimap =
|
ziv@2213
|
10 insertSet (kToVs, k, ValSet.singleton v)
|
ziv@2213
|
11 fun findSet (kToVs : multimap, k : key) =
|
ziv@2203
|
12 case KeyMap.find (kToVs, k) of
|
ziv@2203
|
13 SOME vs => vs
|
ziv@2203
|
14 | NONE => ValSet.empty
|
ziv@2213
|
15 val findList : multimap * key -> item list = ValSet.listItems o findSet
|
ziv@2203
|
16 end
|