# Functor Cf_rbtree.Set

    module Set: functor (E : Cf_ordered.Total_T) -> Cf_set.T  with module Element = E

A functor that produces a module of type `Cf_set` to represent sets with the element type described by `E`.

Parameters:

`E` | : | `Cf_ordered.Total_T`

    type t

The set type

    module Element: sig .. end

A module defining the type of the element.

    val nil : t

The empty set.

    val empty : t -> bool

Use `empty s` to test whether the set `s` is the empty set.

    val size : t -> int

Use `size s` to compute the size of the set `s`.

    val member : Element.t -> t -> bool

Use `member e s` to test whether the element `e` is a member of the set `s`.

    val singleton : Element.t -> t

Use `singleton e` to compose a new set containing only the element `e`.

    val min : t -> Element.t

Use `min s` to return the ordinally least element in the set `s`. Raises `Not_found` if the set is empty.

    val max : t -> Element.t

Use `min s` to return the ordinally greatest element in the set `s`. Raises `Not_found` if the set is empty.

    val put : Element.t -> t -> t

Use `put e s` to obtain a new set produced by inserting the element `e` into the set `s`. If `s` already contains a member ordinally equal to `e` then it is replaced by `e` in the set returned.

    val clear : Element.t -> t -> t

Use `clear e s` to obtain a new set produced by deleting the element in the set `s` ordinally equal to the element `e`. If there is no such element in the set, then the set is returned unchanged.

    val union : t -> t -> t

Use `union s1 s2` to obtain a new set from the union of the sets `s1` and `s2`. Elements of the new set belonging to the intersection are copied from `s2`.

    val diff : t -> t -> t

Use `diff s1 s2` to obtain a new set from the difference of the sets `s1` and `s2`.

    val intersect : t -> t -> t

Use `interset s1 s2` to obtain a new set from the intersection of the sets `s1` and `s2`. All the elements in the new set are copied from `s2`.

    val compare : t -> t -> int

Use `compare s1 s2` to compare the sequence of elements in the set `s1` and the sequence of elements in the set `s2` in order of increasing ordinality. Two sets are ordinally equal if the sequences of their elements are ordinally equal.

    val subset : t -> t -> bool

Use `subset s1 s2` to test whether the set `s1` is a subset of `s2`.

    val of_list : Element.t list -> t

Use `of_list s` to iterate a list of elements and compose a new set by inserting them in order.

    val of_list_incr : Element.t list -> t

Use `of_list_incr s` to compose the set with elements in the ordered list `s`. Runs in linear time if the list `s` is known to be in increasing order. Otherwise, there is an additional linear cost beyond `of_list s`.

    val of_list_decr : Element.t list -> t

Use `of_list_decr s` to compose the set with elements in the ordered list `s`. Runs in linear time if the list `s` is known to be in decreasing order. Otherwise, there is an additional linear cost beyond `of_list s`.

    val of_seq : Element.t Cf_seq.t -> t

Use `of_seq z` to evaluate a sequence of elements and compose a new set by inserting them in order.

    val of_seq_incr : Element.t Cf_seq.t -> t

Use `of_seq_incr z` to compose the set with elements in the ordered sequence `z`. Runs in linear time if the sequence `z` is known to be in increasing order. Otherwise, there is an additional linear cost beyond `of_seq z`.

    val of_seq_decr : Element.t Cf_seq.t -> t

Use `of_seq_decr z` to compose the set with elements in the ordered sequence `z`. Runs in linear time if the sequence `z` is known to be in decreasing order. Otherwise, there is an additional linear cost beyond `of_seq z`.

    val to_list_incr : t -> Element.t list

Use `to_list_incr s` to produce the list of elements in the set `s` in order of increasing ordinality.

    val to_list_decr : t -> Element.t list

Use `to_list_decr s` to produce the list of elements in the set `s` in order of decreasing ordinality.

    val to_seq_incr : t -> Element.t Cf_seq.t

Use `to_seq_incr s` to produce the sequence of elements in the set `s` in order of increasing ordinality.

    val to_seq_decr : t -> Element.t Cf_seq.t

Use `to_seq_decr s` to produce the sequence of elements in the set `s` in order of decreasing ordinality.

    val nearest_decr : Element.t -> t -> Element.t Cf_seq.t

Use `nearest_decr k s` to obtain the key-value pair ordinally less than or equal to the key `k` in the set `s`. Raises `Not_found` if the set is empty or all the keys are ordinally greater.

    val nearest_incr : Element.t -> t -> Element.t Cf_seq.t

Use `nearest_incr k s` to obtain the element ordinally greater than or equal to the key `k` in the set `s`. Raises `Not_found` if the set is empty or all the keys are ordinally less.

    val iterate : (Element.t -> unit) -> t -> unit

Use `iterate f s` to apply the iterator function `f` to every element in the set `s` in arbitrary order (not increasing or decreasing).

    val predicate : (Element.t -> bool) -> t -> bool

Use `predicate f s` to test whether all the elements in the set `s` satisfy the predicate function `f`, visiting the elements in an arbitrary order (not increasing or decreasing) until `f` returns `false` or all elements are tested.

    val fold : ('a -> Element.t -> 'a) -> 'a -> t -> 'a

Use `fold f a s` to fold the elements of the set `s` into the folding function `f` with the initial state `a`, by applying the elements in an arbitrary order (not increasing or decreasing).

    val filter : (Element.t -> bool) -> t -> t

Use `filter f s` to produce a new set comprised of all the elements of the set `s` that satisfy the filtering function `f`, applying the elements in an arbitrary order (not increasing or decreasing).

    val partition : (Element.t -> bool) -> t -> t * t

Use `partition f s` to produce two new sets by applying the partitioning function `f` to every element in the set `s` in an arbitrary order (not increasing or decreasing). The first set returned contains all the elements for which applying `f` returns `true`. The second set returned contains all the elements for which applying `f` returns `false`.