-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdict.sig
executable file
·75 lines (60 loc) · 3.23 KB
/
dict.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
signature DICT =
sig
type key
type 'a dict
exception Absent
val empty : 'a dict
val singleton : key -> 'a -> 'a dict
val insert : 'a dict -> key -> 'a -> 'a dict
val insert' : 'a dict -> key -> 'a -> 'a dict * bool (* true if already present *)
val remove : 'a dict -> key -> 'a dict
val remove' : 'a dict -> key -> 'a dict * bool (* true if present *)
val find : 'a dict -> key -> 'a option
val lookup : 'a dict -> key -> 'a
(* (operate dict key absentf presentf) looks up key in dict. If key maps to x,
it replaces x with (presentf x). If key is absent, it inserts absentf ().
It then returns SOME x (NONE if key was absent), the new value, and the new
dictionary.
*)
val operate : 'a dict -> key -> (unit -> 'a) -> ('a -> 'a) -> 'a option * 'a * 'a dict
(* (operate' dict key absentf presentf) looks up key in dict. If key maps to x,
it evaluates y = presentf(x). If key is absent, it evaluates y = absentf ().
If y = NONE, it deletes the entry; if y = SOME z, it inserts or updates the
entry with z. It then returns SOME x (NONE if key was absent), y, and the new
dictionary.
*)
val operate' : 'a dict -> key -> (unit -> 'a option) -> ('a -> 'a option) -> 'a option * 'a option * 'a dict
(* (insertMerge dict key y presentf) looks up key in dict. If key maps to x,
it replaces x with (presentf x). If key is absent, it insert y. It then
returns the new dictionary.
*)
val insertMerge : 'a dict -> key -> 'a -> ('a -> 'a) -> 'a dict
val isEmpty : 'a dict -> bool
val size : 'a dict -> int
val member : 'a dict -> key -> bool
val toList : 'a dict -> (key * 'a) list
val domain : 'a dict -> key list
val map : ('a -> 'b) -> 'a dict -> 'b dict
val map' : (key * 'a -> 'b) -> 'a dict -> 'b dict
val foldl : (key * 'a * 'b -> 'b) -> 'b -> 'a dict -> 'b
val foldr : (key * 'a * 'b -> 'b) -> 'b -> 'a dict -> 'b
val app : (key * 'a -> unit) -> 'a dict -> unit
(* Uses the supplied function to resolve conflicts when the two dictionaries
include the same key.
*)
val union : 'a dict -> 'a dict -> (key * 'a * 'a -> 'a) -> 'a dict
(* Range searches *)
val partition : 'a dict -> key -> 'a dict * 'a option * 'a dict
val partitionlt : 'a dict -> key -> 'a dict * 'a dict
val partitiongt : 'a dict -> key -> 'a dict * 'a dict
val rangeii : 'a dict -> key -> key -> 'a dict (* inclusive left, inclusive right *)
val rangeie : 'a dict -> key -> key -> 'a dict (* inclusive left, exclusive right *)
val rangeei : 'a dict -> key -> key -> 'a dict (* exclusive left, inclusive right *)
val rangeee : 'a dict -> key -> key -> 'a dict (* exclusive left, exclusive right *)
val least : 'a dict -> key * 'a
val greatest : 'a dict -> key * 'a
val leastGt : 'a dict -> key -> key * 'a
val leastGeq : 'a dict -> key -> key * 'a
val greatestLt : 'a dict -> key -> key * 'a
val greatestLeq : 'a dict -> key -> key * 'a
end