1Map.S(3) OCaml library Map.S(3)
2
3
4
6 Map.S - Output signature of the functor Map.Make.
7
9 Module type Map.S
10
12 Module type S
13 = sig end
14
15
16 Output signature of the functor Map.Make .
17
18
19
20
21
22
23 type key
24
25
26 The type of the map keys.
27
28
29
30 type +'a t
31
32
33 The type of maps from type key to type 'a .
34
35
36
37
38 val empty : 'a t
39
40 The empty map.
41
42
43
44
45 val is_empty : 'a t -> bool
46
47 Test whether a map is empty or not.
48
49
50
51
52 val add : key -> 'a -> 'a t -> 'a t
53
54
55 add x y m returns a map containing the same bindings as m , plus a
56 binding of x to y . If x was already bound in m , its previous binding
57 disappears.
58
59
60
61
62 val find : key -> 'a t -> 'a
63
64
65 find x m returns the current binding of x in m , or raises Not_found if
66 no such binding exists.
67
68
69
70
71 val remove : key -> 'a t -> 'a t
72
73
74 remove x m returns a map containing the same bindings as m , except for
75 x which is unbound in the returned map.
76
77
78
79
80 val mem : key -> 'a t -> bool
81
82
83 mem x m returns true if m contains a binding for x , and false other‐
84 wise.
85
86
87
88
89 val iter : (key -> 'a -> unit) -> 'a t -> unit
90
91
92 iter f m applies f to all bindings in map m . f receives the key as
93 first argument, and the associated value as second argument. The bind‐
94 ings are passed to f in increasing order with respect to the ordering
95 over the type of the keys. Only current bindings are presented to f :
96 bindings hidden by more recent bindings are not passed to f .
97
98
99
100
101 val map : ('a -> 'b) -> 'a t -> 'b t
102
103
104 map f m returns a map with same domain as m , where the associated
105 value a of all bindings of m has been replaced by the result of the
106 application of f to a . The bindings are passed to f in increasing
107 order with respect to the ordering over the type of the keys.
108
109
110
111
112 val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
113
114 Same as Map.S.map , but the function receives as arguments both the key
115 and the associated value for each binding of the map.
116
117
118
119
120 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
121
122
123 fold f m a computes (f kN dN ... (f k1 d1 a)...) , where k1 ... kN are
124 the keys of all bindings in m (in increasing order), and d1 ... dN are
125 the associated data.
126
127
128
129
130 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
131
132 Total ordering between maps. The first argument is a total ordering
133 used to compare data associated with equal keys in the two maps.
134
135
136
137
138 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
139
140
141 equal cmp m1 m2 tests whether the maps m1 and m2 are equal, that is,
142 contain equal keys and associate them with equal data. cmp is the
143 equality predicate used to compare the data associated with the keys.
144
145
146
147
148
149
150OCamldoc 2007-05-24 Map.S(3)