Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 101 lines (88 sloc) 3.281 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 module type S =
19 sig
20 type elt
21 type t
22 val empty : t
23 val is_empty : t -> bool
24 val mem : elt -> t -> bool
25 val add : elt -> t -> t
26 val add_list : elt list -> t -> t
27 val singleton : elt -> t
28 val remove : elt -> t -> t
29 val union : t -> t -> t
30
31 (**
32 Ensures that sets are disjoints. Else, fails raising
33 [Invalid_argument "Base.Set.safe_union"]
34 @raise Invalid_argument if the sets are not disjoints.
35 *)
36 val safe_union : t -> t -> t
37 val inter : t -> t -> t
38 val diff : t -> t -> t
39 val compare : t -> t -> int
40 val equal : t -> t -> bool
41
42 (**
43 [subset s1 s2] tests whether the set s1 is a subset of the set s2 .
44 *)
45 val subset : t -> t -> bool
46 val iter : (elt -> unit) -> t -> unit
47 val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
48 val fold_rev : (elt -> 'a -> 'a) -> t -> 'a -> 'a
49 val map : (elt -> elt) -> t -> t
50 val for_all : (elt -> bool) -> t -> bool
51 val exists : (elt -> bool) -> t -> bool
52 val filter : (elt -> bool) -> t -> t
53 val partition : (elt -> bool) -> t -> t * t
54 val cardinal : t -> int
55 val elements : t -> elt list
56 val from_list : elt list -> t
57 val min_elt : t -> elt
58 val max_elt : t -> elt
5b18026 [enhance] Stdlib: Comments in Standard Library
Arthur Milchior authored
59
60 (**
61 Returns an arbitrary element of the set.
62 @raise Not_found on the empty set
63 *)
fccc685 Initial open-source release
MLstate authored
64 val choose : t -> elt
e74f6b5 [feature] libbase: choose_opt in Maps and Sets
Arthur Milchior authored
65
66 (**
67 Returns an arbitrary element of the set if it is not empty
68 *)
69 val choose_opt : t -> elt option
645f07a [feature] libbase: Taking an element to show the difference between two...
Arthur Milchior authored
70
71 (**
72 If the two set are different, give back an element in the left set not in
73 the right one, or in the right one not in the left one, or None
74 We cannot use there [elt Base.either option], because this would create
75 a circular build. If needed, we can return a variant indicating where
76 the element was found.
77 *)
78 val example_diff : t -> t -> elt option
fccc685 Initial open-source release
MLstate authored
79 val split : elt -> t -> t * bool * t
80 val draw : t -> elt * t
81 val size : t -> int
82 val complete : (elt -> elt -> bool) -> elt -> t -> t
83
84 (** Binding with Format for printing.
85 The first argument is a separator which will be
86 printed after each elt of the set.
87 If you does not want to see the separator after the last element, use an intermediate
88 list traduction. *)
89 val pp : (unit, Format.formatter, unit) format -> (Format.formatter -> elt -> unit) -> Format.formatter -> t -> unit
90
91 (** exporting the Arg.compare *)
92 val compare_elt : elt -> elt -> int
93
94 (**
95 Optimized initialization for huge maps, to avoid temporary unused balancing.
96 The array should be sorted in increasing order, using the same order than the set.
97 <!> Unoptimized on IntMap
98 *)
99 val from_sorted_array : elt array -> t
100 end
Something went wrong with that request. Please try again.