1Misc.Stdlib.String.Set(3)        OCaml library       Misc.Stdlib.String.Set(3)
2
3
4

NAME

6       Misc.Stdlib.String.Set - no description
7

Module

9       Module   Misc.Stdlib.String.Set
10

Documentation

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