-
Notifications
You must be signed in to change notification settings - Fork 4
/
maps.sig
executable file
·45 lines (28 loc) · 1.58 KB
/
maps.sig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(*======================================================================
This is another dictionary signature, except that instead of assuming that
every key can be mapped to an integer, this dictionary works with a given
total comparison function that maps any two keys to a value of type order
(note: order is a built-in SML datatype with three nullary constructors,
LESS, EQUAL, and GREATER).
=======================================================================*)
signature OMAP =
sig
type ('a, 'b) mapping
exception MapEx
val makeMap : (('a * 'a) -> order) -> ('a,'b) mapping
val insert: (('a,'b) mapping) * 'a * 'b -> ('a,'b) mapping
val insertLst: (('a,'b) mapping) * (('a * 'b) list) -> ('a,'b) mapping
val find: (('a,'b) mapping) * 'a -> 'b option
val remove : ('a,'b) mapping * 'a -> ('a,'b) mapping * 'b
(* Remove an item, returning new map and value removed. Raises MapEx if not found. *)
val size: ('a,'b) mapping -> int
val listKeys: ('a,'b) mapping -> 'a list
val listValues: ('a,'b) mapping -> 'b list
val listKeyValuePairs: ('a,'b) mapping -> ('a * 'b) list
val applyToKeys: ('a -> unit) * ('a,'b) mapping -> unit
val applyToValues: ('b -> unit) * ('a,'b) mapping -> unit
val applyToKeyValuePairs: (('a * 'b) -> unit) * ('a,'b) mapping -> unit
val mapToKeyValuePairs: (('a * 'b) -> 'b) * ('a,'b) mapping -> ('a,'b) mapping
val mapToValues: ('b -> 'b) * ('a,'b) mapping -> ('a,'b) mapping
val foldl: ('key_type * 'value_type * 'a -> 'a) * 'a * ('key_type, 'value_type) mapping -> 'a
end