logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Set.S - Output signature of the functor Set.Make.

Documentation

       Module type S
        = sigend

       Output signature of the functor Set.Make .

   Setstypeelt

       The type of the set elements.

       typet

       The type of sets.

       valempty : t

       The empty set.

       valadd : elt->t->taddxs  returns  a  set  containing all elements of s , plus x . If x was already in s , s is returned
       unchanged (the result of the function is then physically equal to s ).

       Before4.03 Physical equality was not ensured.

       valsingleton : elt->tsingletonx returns the one-element set containing only x .

       valremove : elt->t->tremovexs returns a set containing all elements of s , except x . If x was not in  s  ,  s  is  returned
       unchanged (the result of the function is then physically equal to s ).

       Before4.03 Physical equality was not ensured.

       valunion : t->t->t

       Set union.

       valinter : t->t->t

       Set intersection.

       valdisjoint : t->t->bool

       Test if two sets are disjoint.

       Since 4.08

       valdiff : t->t->t

       Set difference: diffs1s2 contains the elements of s1 that are not in s2 .

       valcardinal : t->int

       Return the number of elements of a set.

   Elementsvalelements : t->eltlist

       Return  the  list of all elements of the given set.  The returned list is sorted in increasing order with
       respect to the ordering Ord.compare , where Ord is the argument given to Set.Make .

       valmin_elt : t->elt

       Return the smallest element of the given set  (with  respect  to  the  Ord.compare  ordering),  or  raise
       Not_found if the set is empty.

       valmin_elt_opt : t->eltoption

       Return  the  smallest element of the given set (with respect to the Ord.compare ordering), or None if the
       set is empty.

       Since 4.05

       valmax_elt : t->elt

       Same as Set.S.min_elt , but returns the largest element of the given set.

       valmax_elt_opt : t->eltoption

       Same as Set.S.min_elt_opt , but returns the largest element of the given set.

       Since 4.05

       valchoose : t->elt

       Return one element of the given set, or raise Not_found if the set is empty. Which element is  chosen  is
       unspecified, but equal elements will be chosen for equal sets.

       valchoose_opt : t->eltoption

       Return one element of the given set, or None if the set is empty. Which element is chosen is unspecified,
       but equal elements will be chosen for equal sets.

       Since 4.05

   Searchingvalfind : elt->t->eltfindxs returns the element of s equal to x (according to Ord.compare ), or raise Not_found if no such
       element exists.

       Since 4.01

       valfind_opt : elt->t->eltoptionfind_optxs returns the element of s equal to x (according to Ord.compare ), or None if no such  element
       exists.

       Since 4.05

       valfind_first : (elt->bool)->t->eltfind_firstfs , where f is a monotonically increasing function, returns the lowest element e of s such
       that fe , or raises Not_found if no such element exists.

       For example, find_first(fune->Ord.compareex>=0)s will return the first  element  e  of  s  where
       Ord.compareex>=0 (intuitively: e>=x ), or raise Not_found if x is greater than any element of s .

       Since 4.05

       valfind_first_opt : (elt->bool)->t->eltoptionfind_first_optfs  ,  where f is a monotonically increasing function, returns an option containing the
       lowest element e of s such that fe , or None if no such element exists.

       Since 4.05

       valfind_last : (elt->bool)->t->eltfind_lastfs , where f is a monotonically decreasing function, returns the highest element e of  s  such
       that fe , or raises Not_found if no such element exists.

       Since 4.05

       valfind_last_opt : (elt->bool)->t->eltoptionfind_last_optfs  ,  where  f is a monotonically decreasing function, returns an option containing the
       highest element e of s such that fe , or None if no such element exists.

       Since 4.05

   Traversingvaliter : (elt->unit)->t->unititerfs applies f in turn to all elements of s .  The elements of s are presented  to  f  in  increasing
       order with respect to the ordering over the type of the elements.

       valfold : (elt->'acc->'acc)->t->'acc->'accfoldfsinit  computes (fxN...(fx2(fx1init))...)  , where x1...xN are the elements of s , in
       increasing order.

   Transformingvalmap : (elt->elt)->t->tmapfs is the set whose elements are fa0 , fa1 ...  faN , where a0 , a1 ...  aN are the elements of s .

       The elements are passed to f in increasing order with respect to  the  ordering  over  the  type  of  the
       elements.

       If no element of s is changed by f , s is returned unchanged. (If each output of f is physically equal to
       its input, the returned set is physically equal to s .)

       Since 4.04

       valfilter : (elt->bool)->t->tfilterfs returns the set of all elements in s that satisfy predicate f . If f satisfies every element
       in s , s is returned unchanged (the result of the function is then physically equal to s ).

       Before4.03 Physical equality was not ensured.

       valfilter_map : (elt->eltoption)->t->tfilter_mapfs returns the set of all v such that fx=Somev for some element x of s .

       For example,
       filter_map(funn->ifnmod2=0thenSome(n/2)elseNone)s
       is the set of halves of the even elements of s .

       If no element of s is changed or dropped by f (if fx=Somex for each element x ), then s  is  returned
       unchanged: the result of the function is then physically equal to s .

       Since 4.11

       valpartition : (elt->bool)->t->t*tpartitionfs returns a pair of sets (s1,s2) , where s1 is the set of all the elements of s that satisfy
       the predicate f , and s2 is the set of all the elements of s that do not satisfy f .

       valsplit : elt->t->t*bool*tsplitxs returns a triple (l,present,r) , where l is the set of elements of s that are strictly less
       than x ; r is the set of elements of s that are strictly greater than x ; present is false if s  contains
       no element equal to x , or true if s contains an element equal to x .

   Predicatesandcomparisonsvalis_empty : t->bool

       Test whether a set is empty or not.

       valmem : elt->t->boolmemxs tests whether x belongs to the set s .

       valequal : t->t->boolequals1s2 tests whether the sets s1 and s2 are equal, that is, contain equal elements.

       valcompare : t->t->int

       Total ordering between sets. Can be used as the ordering function for doing sets of sets.

       valsubset : t->t->boolsubsets1s2 tests whether the set s1 is a subset of the set s2 .

       valfor_all : (elt->bool)->t->boolfor_allfs checks if all elements of the set satisfy the predicate f .

       valexists : (elt->bool)->t->boolexistsfs checks if at least one element of the set satisfies the predicate f .

   Convertingvalto_list : t->eltlistto_lists is Set.S.elementss .

       Since 5.1

       valof_list : eltlist->tof_listl  creates  a set from a list of elements.  This is usually more efficient than folding add over
       the list, except perhaps for lists with many duplicated elements.

       Since 4.02

       valto_seq_from : elt->t->eltSeq.tto_seq_fromxs iterates on a subset of the elements of s in ascending order, from x or above.

       Since 4.07

       valto_seq : t->eltSeq.t

       Iterate on the whole set, in ascending order

       Since 4.07

       valto_rev_seq : t->eltSeq.t

       Iterate on the whole set, in descending order

       Since 4.12

       valadd_seq : eltSeq.t->t->t

       Add the given elements to the set, in order.

       Since 4.07

       valof_seq : eltSeq.t->t

       Build a set from the given bindings

       Since 4.07

OCamldoc                                           2025-06-12                                          Set.S(3o)

Module Type

       Module type   Set.S

Name

       Set.S - Output signature of the functor Set.Make.

See Also