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. Only current bindings are presented to f :
107 bindings hidden by more recent bindings are not passed to f .
108
109
110
111
112 val map : ('a -> 'b) -> 'a t -> 'b t
113
114
115 map f m returns a map with same domain as m , where the associated
116 value a of all bindings of m has been replaced by the result of the
117 application of f to a . The bindings are passed to f in increasing
118 order with respect to the ordering over the type of the keys.
119
120
121
122
123 val mapi : (key -> 'a -> 'b) -> 'a t -> 'b t
124
125 Same as Map.S.map , but the function receives as arguments both the key
126 and the associated value for each binding of the map.
127
128
129
130
131 val fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
132
133
134 fold f m a computes (f kN dN ... (f k1 d1 a)...) , where k1 ... kN are
135 the keys of all bindings in m (in increasing order), and d1 ... dN are
136 the associated data.
137
138
139
140
141 val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
142
143 Total ordering between maps. The first argument is a total ordering
144 used to compare data associated with equal keys in the two maps.
145
146
147
148
149 val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
150
151
152 equal cmp m1 m2 tests whether the maps m1 and m2 are equal, that is,
153 contain equal keys and associate them with equal data. cmp is the
154 equality predicate used to compare the data associated with the keys.
155
156
157
158
159
160
161OCamldoc 2007-05-24 Map.Make(3)