diff src/multimap_fn.sml @ 2213:365727ff68f4

Complete overhaul: cache queries based on immediate query result, not eventual HTML output.
author Ziv Scully <ziv@mit.edu>
date Tue, 14 Oct 2014 18:05:09 -0400
parents 39faa4a037f4
children
line wrap: on
line diff
--- a/src/multimap_fn.sml	Mon Sep 15 20:01:16 2014 -0400
+++ b/src/multimap_fn.sml	Tue Oct 14 18:05:09 2014 -0400
@@ -1,14 +1,16 @@
 functor MultimapFn (structure KeyMap : ORD_MAP structure ValSet : ORD_SET) = struct
     type key = KeyMap.Key.ord_key
     type item = ValSet.item
-    type items = ValSet.set
+    type itemSet = ValSet.set
     type multimap = ValSet.set KeyMap.map
-    fun inserts (kToVs : multimap, k : key, vs : items) : multimap =
+    val empty : multimap = KeyMap.empty
+    fun insertSet (kToVs : multimap, k : key, vs : itemSet) : multimap =
         KeyMap.unionWith ValSet.union (kToVs, KeyMap.singleton (k, vs))
     fun insert (kToVs : multimap, k : key, v : item) : multimap =
-        inserts (kToVs, k, ValSet.singleton v)
-    fun find (kToVs : multimap, k : key) =
+        insertSet (kToVs, k, ValSet.singleton v)
+    fun findSet (kToVs : multimap, k : key) =
         case KeyMap.find (kToVs, k) of
             SOME vs => vs
           | NONE => ValSet.empty
+    val findList : multimap * key -> item list = ValSet.listItems o findSet
 end