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       Parameters:
22
23       "Ord"
24
25       Set.OrderedType
26
27
28
29
30
31
32
33       type elt
34
35
36       The type of the set elements.
37
38
39       type t
40
41
42       The type of sets.
43
44
45
46       val empty : t
47
48       The empty set.
49
50
51
52       val is_empty : t -> bool
53
54       Test whether a set is empty or not.
55
56
57
58       val mem : elt -> t -> bool
59
60
61       mem x s tests whether x belongs to the set s .
62
63
64
65       val add : elt -> t -> t
66
67
68       add  x s returns a set containing all elements of s , plus x . If x was
69       already in s , s is returned unchanged (the result of the  function  is
70       then physically equal to s ).
71
72
73       Before4.03 Physical equality was not ensured.
74
75
76
77
78       val singleton : elt -> t
79
80
81       singleton x returns the one-element set containing only x .
82
83
84
85       val remove : elt -> t -> t
86
87
88       remove x s returns a set containing all elements of s , except x . If x
89       was not in s , s is returned unchanged (the result of the  function  is
90       then physically equal to s ).
91
92
93       Before4.03 Physical equality was not ensured.
94
95
96
97
98       val union : t -> t -> t
99
100       Set union.
101
102
103
104       val inter : t -> t -> t
105
106       Set intersection.
107
108
109
110       val disjoint : t -> t -> bool
111
112       Test if two sets are disjoint.
113
114
115       Since 4.08.0
116
117
118
119       val diff : t -> t -> t
120
121       Set  difference: diff s1 s2 contains the elements of s1 that are not in
122       s2 .
123
124
125
126       val compare : t -> t -> int
127
128       Total ordering between sets. Can be used as the ordering  function  for
129       doing sets of sets.
130
131
132
133       val equal : t -> t -> bool
134
135
136       equal  s1  s2 tests whether the sets s1 and s2 are equal, that is, con‐
137       tain equal elements.
138
139
140
141       val subset : t -> t -> bool
142
143
144       subset s1 s2 tests whether the set s1 is a subset of the set s2 .
145
146
147
148       val iter : (elt -> unit) -> t -> unit
149
150
151       iter f s applies f in turn to all elements of s .  The  elements  of  s
152       are  presented  to  f  in increasing order with respect to the ordering
153       over the type of the elements.
154
155
156
157       val map : (elt -> elt) -> t -> t
158
159
160       map f s is the set whose elements are f a0 , f a1 ...  f
161               aN , where a0 , a1 ...  aN are the elements of s .
162
163       The elements are passed to f in increasing order with  respect  to  the
164       ordering over the type of the elements.
165
166       If  no element of s is changed by f , s is returned unchanged. (If each
167       output of f is physically equal to its input, the returned set is phys‐
168       ically equal to s .)
169
170
171       Since 4.04.0
172
173
174
175       val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
176
177
178       fold  f  s  a computes (f xN ... (f x2 (f x1 a))...)  , where x1 ... xN
179       are the elements of s , in increasing order.
180
181
182
183       val for_all : (elt -> bool) -> t -> bool
184
185
186       for_all p s checks if all elements of the set satisfy the predicate p .
187
188
189
190       val exists : (elt -> bool) -> t -> bool
191
192
193       exists p s checks if at least one element  of  the  set  satisfies  the
194       predicate p .
195
196
197
198       val filter : (elt -> bool) -> t -> t
199
200
201       filter  p s returns the set of all elements in s that satisfy predicate
202       p . If p satisfies every element in s , s is  returned  unchanged  (the
203       result of the function is then physically equal to s ).
204
205
206       Before4.03 Physical equality was not ensured.
207
208
209
210
211       val partition : (elt -> bool) -> t -> t * t
212
213
214       partition  p s returns a pair of sets (s1, s2) , where s1 is the set of
215       all the elements of s that satisfy the predicate p , and s2 is the  set
216       of all the elements of s that do not satisfy p .
217
218
219
220       val cardinal : t -> int
221
222       Return the number of elements of a set.
223
224
225
226       val elements : t -> elt list
227
228       Return the list of all elements of the given set.  The returned list is
229       sorted in increasing order with respect to the ordering  Ord.compare  ,
230       where Ord is the argument given to Set.Make .
231
232
233
234       val min_elt : t -> elt
235
236       Return  the  smallest  element  of  the  given set (with respect to the
237       Ord.compare ordering), or raise Not_found if the set is empty.
238
239
240
241       val min_elt_opt : t -> elt option
242
243       Return the smallest element of the  given  set  (with  respect  to  the
244       Ord.compare ordering), or None if the set is empty.
245
246
247       Since 4.05
248
249
250
251       val max_elt : t -> elt
252
253       Same  as  Set.S.min_elt  , but returns the largest element of the given
254       set.
255
256
257
258       val max_elt_opt : t -> elt option
259
260       Same as Set.S.min_elt_opt , but returns  the  largest  element  of  the
261       given set.
262
263
264       Since 4.05
265
266
267
268       val choose : t -> elt
269
270       Return  one  element of the given set, or raise Not_found if the set is
271       empty. Which element is chosen is unspecified, but equal elements  will
272       be chosen for equal sets.
273
274
275
276       val choose_opt : t -> elt option
277
278       Return one element of the given set, or None if the set is empty. Which
279       element is chosen is unspecified, but equal elements will be chosen for
280       equal sets.
281
282
283       Since 4.05
284
285
286
287       val split : elt -> t -> t * bool * t
288
289
290       split x s returns a triple (l, present, r) , where l is the set of ele‐
291       ments of s that are strictly less than x ; r is the set of elements  of
292       s  that are strictly greater than x ; present is false if s contains no
293       element equal to x , or true if s contains an element equal to x .
294
295
296
297       val find : elt -> t -> elt
298
299
300       find x s returns the element of s equal to x (according to  Ord.compare
301       ), or raise Not_found if no such element exists.
302
303
304       Since 4.01.0
305
306
307
308       val find_opt : elt -> t -> elt option
309
310
311       find_opt x s returns the element of s equal to x (according to Ord.com‐
312       pare ), or None if no such element exists.
313
314
315       Since 4.05
316
317
318
319       val find_first : (elt -> bool) -> t -> elt
320
321
322       find_first f s ,  where  f  is  a  monotonically  increasing  function,
323       returns  the  lowest element e of s such that f e , or raises Not_found
324       if no such element exists.
325
326       For example, find_first (fun e -> Ord.compare e x >= 0) s  will  return
327       the  first element e of s where Ord.compare e x >= 0 (intuitively: e >=
328       x ), or raise Not_found if x is greater than any element of s .
329
330
331       Since 4.05
332
333
334
335       val find_first_opt : (elt -> bool) -> t -> elt option
336
337
338       find_first_opt f s , where f is a  monotonically  increasing  function,
339       returns  an option containing the lowest element e of s such that f e ,
340       or None if no such element exists.
341
342
343       Since 4.05
344
345
346
347       val find_last : (elt -> bool) -> t -> elt
348
349
350       find_last f s , where f is a monotonically decreasing function, returns
351       the  highest  element  e of s such that f e , or raises Not_found if no
352       such element exists.
353
354
355       Since 4.05
356
357
358
359       val find_last_opt : (elt -> bool) -> t -> elt option
360
361
362       find_last_opt f s , where f is  a  monotonically  decreasing  function,
363       returns an option containing the highest element e of s such that f e ,
364       or None if no such element exists.
365
366
367       Since 4.05
368
369
370
371       val of_list : elt list -> t
372
373
374       of_list l creates a set from a list of elements.  This is usually  more
375       efficient than folding add over the list, except perhaps for lists with
376       many duplicated elements.
377
378
379       Since 4.02.0
380
381
382
383
384   Iterators
385       val to_seq_from : elt -> t -> elt Seq.t
386
387
388       to_seq_from x s iterates on a subset of the elements of s in  ascending
389       order, from x or above.
390
391
392       Since 4.07
393
394
395
396       val to_seq : t -> elt Seq.t
397
398       Iterate on the whole set, in ascending order
399
400
401       Since 4.07
402
403
404
405       val add_seq : elt Seq.t -> t -> t
406
407       Add the given elements to the set, in order.
408
409
410       Since 4.07
411
412
413
414       val of_seq : elt Seq.t -> t
415
416       Build a set from the given bindings
417
418
419       Since 4.07
420
421
422
423
424
425OCamldoc                          2020-02-27                       Set.Make(3)
Impressum