functor TREEDICT( structure T : BTreeSig type Key val < : Key * Key -> bool type Item ) : DictSig = let structure TS = TREESET(structure T = T type Item = Key * Item val op < = fn ((k, _), (k', _)) => k < k' ) in struct open T exception Lookup type Dict = (Key * Item) Tree type Key = Key type Item = Item val empty = TS.empty val enter = TS.insert fun lookup Lf k = raise Lookup | lookup (Nd(lt, (k',e), rt)) k = if k < k' then lookup lt k else if k' < k then lookup rt k else e ; fun remove(k, d) = let val e = lookup d k in TS.delete((k,e), d) end handle Lookup => d end end