1Set.Make(3)                      OCaml library                     Set.Make(3)
2
3
4

NAME

6       Set.Make  -  Functor  building  an  implementation of the set structure
7       given a totally ordered type.
8

Module

10       Module   Set.Make
11

Documentation

13       Module Make
14        : functor (Ord : OrderedType) -> sig end
15
16
17       Functor building an implementation of the set structure given a totally
18       ordered type.
19
20
21
22       Parameters:
23
24       "Ord"
25
26       Set.OrderedType
27
28
29
30
31
32
33
34       type elt
35
36
37       The type of the set elements.
38
39
40
41       type t
42
43
44       The type of sets.
45
46
47
48
49       val empty : t
50
51       The empty set.
52
53
54
55
56       val is_empty : t -> bool
57
58       Test whether a set is empty or not.
59
60
61
62
63       val mem : elt -> t -> bool
64
65
66       mem x s tests whether x belongs to the set s .
67
68
69
70
71       val add : elt -> t -> t
72
73
74       add  x s returns a set containing all elements of s , plus x . If x was
75       already in s , s is returned unchanged.
76
77
78
79
80       val singleton : elt -> t
81
82
83       singleton x returns the one-element set containing only x .
84
85
86
87
88       val remove : elt -> t -> t
89
90
91       remove x s returns a set containing all elements of s , except x . If x
92       was not in s , s is returned unchanged.
93
94
95
96
97       val union : t -> t -> t
98
99       Set union.
100
101
102
103
104       val inter : t -> t -> t
105
106       Set intersection.
107
108
109
110
111       val diff : t -> t -> t
112
113       Set difference.
114
115
116
117
118       val compare : t -> t -> int
119
120       Total  ordering  between sets. Can be used as the ordering function for
121       doing sets of sets.
122
123
124
125
126       val equal : t -> t -> bool
127
128
129       equal s1 s2 tests whether the sets s1 and s2 are equal, that  is,  con‐
130       tain equal elements.
131
132
133
134
135       val subset : t -> t -> bool
136
137
138       subset s1 s2 tests whether the set s1 is a subset of the set s2 .
139
140
141
142
143       val iter : (elt -> unit) -> t -> unit
144
145
146       iter  f  s  applies f in turn to all elements of s .  The elements of s
147       are presented to f in increasing order with  respect  to  the  ordering
148       over the type of the elements.
149
150
151
152
153       val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
154
155
156       fold  f  s  a computes (f xN ... (f x2 (f x1 a))...)  , where x1 ... xN
157       are the elements of s , in increasing order.
158
159
160
161
162       val for_all : (elt -> bool) -> t -> bool
163
164
165       for_all p s checks if all elements of the set satisfy the predicate p .
166
167
168
169
170       val exists : (elt -> bool) -> t -> bool
171
172
173       exists p s checks if at least one element  of  the  set  satisfies  the
174       predicate p .
175
176
177
178
179       val filter : (elt -> bool) -> t -> t
180
181
182       filter  p s returns the set of all elements in s that satisfy predicate
183       p .
184
185
186
187
188       val partition : (elt -> bool) -> t -> t * t
189
190
191       partition p s returns a pair of sets (s1, s2) , where s1 is the set  of
192       all  the elements of s that satisfy the predicate p , and s2 is the set
193       of all the elements of s that do not satisfy p .
194
195
196
197
198       val cardinal : t -> int
199
200       Return the number of elements of a set.
201
202
203
204
205       val elements : t -> elt list
206
207       Return the list of all elements of the given set.  The returned list is
208       sorted  in  increasing order with respect to the ordering Ord.compare ,
209       where Ord is the argument given to Set.Make .
210
211
212
213
214       val min_elt : t -> elt
215
216       Return the smallest element of the  given  set  (with  respect  to  the
217       Ord.compare ordering), or raise Not_found if the set is empty.
218
219
220
221
222       val max_elt : t -> elt
223
224       Same  as  Set.S.min_elt  , but returns the largest element of the given
225       set.
226
227
228
229
230       val choose : t -> elt
231
232       Return one element of the given set, or raise Not_found if the  set  is
233       empty.  Which element is chosen is unspecified, but equal elements will
234       be chosen for equal sets.
235
236
237
238
239       val split : elt -> t -> t * bool * t
240
241
242       split x s returns a triple (l, present, r) , where l is the set of ele‐
243       ments  of s that are strictly less than x ; r is the set of elements of
244       s that are strictly greater than x ; present is false if s contains  no
245       element equal to x , or true if s contains an element equal to x .
246
247
248
249
250
251
252OCamldoc                          2017-03-22                       Set.Make(3)
Impressum