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