1MoreLabels.Set.S(3)              OCaml library             MoreLabels.Set.S(3)
2
3
4

NAME

6       MoreLabels.Set.S - Output signature of the functor MoreLabels.Set.Make.
7

Module type

9       Module type   MoreLabels.Set.S
10

Documentation

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