.TH "Set.S" 3 2008-04-15 OCamldoc "OCaml library"
.SH NAME
Set.S \- Output signature of the functor Set.Make.
.SH Module type
Module type   Set.S
.SH Documentation
.sp
Module type
.BI "S"
 = 
.B sig  end

.sp
Output signature of the functor 
.B Set\&.Make
\&.
.sp

.sp

.sp
.sp
.I type elt 

.sp
The type of the set elements\&.
.sp

.sp
.I type t 

.sp
The type of sets\&.
.sp

.sp

.I val empty 
: 
.B t
.sp
The empty set\&.
.sp

.sp

.I val is_empty 
: 
.B t -> bool
.sp
Test whether a set is empty or not\&.
.sp

.sp

.I val mem 
: 
.B elt -> t -> bool
.sp

.B mem x s
tests whether 
.B x
belongs to the set 
.B s
\&.
.sp

.sp

.I val add 
: 
.B elt -> t -> t
.sp

.B add x s
returns a set containing all elements of 
.B s
,
plus 
.B x
\&. If 
.B x
was already in 
.B s
, 
.B s
is returned unchanged\&.
.sp

.sp

.I val singleton 
: 
.B elt -> t
.sp

.B singleton x
returns the one-element set containing only 
.B x
\&.
.sp

.sp

.I val remove 
: 
.B elt -> t -> t
.sp

.B remove x s
returns a set containing all elements of 
.B s
,
except 
.B x
\&. If 
.B x
was not in 
.B s
, 
.B s
is returned unchanged\&.
.sp

.sp

.I val union 
: 
.B t -> t -> t
.sp
Set union\&.
.sp

.sp

.I val inter 
: 
.B t -> t -> t
.sp
Set intersection\&.
.sp

.sp

.I val diff 
: 
.B t -> t -> t
.sp
Set difference\&.
.sp

.sp

.I val compare 
: 
.B t -> t -> int
.sp
Total ordering between sets\&. Can be used as the ordering function
for doing sets of sets\&.
.sp

.sp

.I val equal 
: 
.B t -> t -> bool
.sp

.B equal s1 s2
tests whether the sets 
.B s1
and 
.B s2
are
equal, that is, contain equal elements\&.
.sp

.sp

.I val subset 
: 
.B t -> t -> bool
.sp

.B subset s1 s2
tests whether the set 
.B s1
is a subset of
the set 
.B s2
\&.
.sp

.sp

.I val iter 
: 
.B (elt -> unit) -> t -> unit
.sp

.B iter f s
applies 
.B f
in turn to all elements of 
.B s
\&.
The elements of 
.B s
are presented to 
.B f
in increasing order
with respect to the ordering over the type of the elements\&.
.sp

.sp

.I val fold 
: 
.B (elt -> 'a -> 'a) -> t -> 'a -> 'a
.sp

.B fold f s a
computes 
.B (f xN \&.\&.\&. (f x2 (f x1 a))\&.\&.\&.)
,
where 
.B x1 \&.\&.\&. xN
are the elements of 
.B s
, in increasing order\&.
.sp

.sp

.I val for_all 
: 
.B (elt -> bool) -> t -> bool
.sp

.B for_all p s
checks if all elements of the set
satisfy the predicate 
.B p
\&.
.sp

.sp

.I val exists 
: 
.B (elt -> bool) -> t -> bool
.sp

.B exists p s
checks if at least one element of
the set satisfies the predicate 
.B p
\&.
.sp

.sp

.I val filter 
: 
.B (elt -> bool) -> t -> t
.sp

.B filter p s
returns the set of all elements in 
.B s
that satisfy predicate 
.B p
\&.
.sp

.sp

.I val partition 
: 
.B (elt -> bool) -> t -> t * t
.sp

.B partition p s
returns a pair of sets 
.B (s1, s2)
, where
.B s1
is the set of all the elements of 
.B s
that satisfy the
predicate 
.B p
, and 
.B s2
is the set of all the elements of
.B s
that do not satisfy 
.B p
\&.
.sp

.sp

.I val cardinal 
: 
.B t -> int
.sp
Return the number of elements of a set\&.
.sp

.sp

.I val elements 
: 
.B t -> elt list
.sp
Return the list of all elements of the given set\&.
The returned list is sorted in increasing order with respect
to the ordering 
.B Ord\&.compare
, where 
.B Ord
is the argument
given to 
.B Set\&.Make
\&.
.sp

.sp

.I val min_elt 
: 
.B t -> elt
.sp
Return the smallest element of the given set
(with respect to the 
.B Ord\&.compare
ordering), or raise
.B Not_found
if the set is empty\&.
.sp

.sp

.I val max_elt 
: 
.B t -> elt
.sp
Same as 
.B Set\&.S\&.min_elt
, but returns the largest element of the
given set\&.
.sp

.sp

.I val choose 
: 
.B t -> elt
.sp
Return one element of the given set, or raise 
.B Not_found
if
the set is empty\&. Which element is chosen is unspecified,
but equal elements will be chosen for equal sets\&.
.sp

.sp

.I val split 
: 
.B elt -> t -> t * bool * t
.sp

.B split x s
returns a triple 
.B (l, present, r)
, where
.B l
is the set of elements of 
.B s
that are
strictly less than 
.B x
;
.B r
is the set of elements of 
.B s
that are
strictly greater than 
.B x
;
.B present
is 
.B false
if 
.B s
contains no element equal to 
.B x
,
or 
.B true
if 
.B s
contains an element equal to 
.B x
\&.
.sp

.sp
