Module type Prime_enumset.S_with_monadic
include S
val empty : t
The empty set.
val is_empty : t -> bool
Holds for the empty set only.
val cardinal : t -> int
cardinal s
is the cardinality ofs
.
val locate : elt -> t -> bool * int
locate e s
is a pair(present, pos)
wherepresent
is true iffe
is a member ofs
, andpos
is the number of elements ofs
which precedese
.
val min_elt_exn : t -> elt
min_elt_exn s
is the smallest element ofs
.- raises Not_found
if the set is empty.
val max_elt_exn : t -> elt
max_elt_exn s
is the largest element ofs
.- raises Not_found
if the set is empty.
val cut_element : elt -> t -> bool * t * t
cut_element k s
is(contains k s, sL, sR)
wheresL
andsR
are the subsets ofs
with keys smaller and larger thank
, respectively.
val pop_min_exn : t -> elt * t
pop_min_exn s
is(e, s')
wheree
is the smallest element ofs
ands'
contains the remaining elements.- raises Not_found
if the set is empty.
val pop_max_exn : t -> elt * t
pop_max_exn s
is(e, s')
wheree
is the largest element ofs
ands'
contains the remaining elements.- raises Not_found
if the set is empty.
val of_ordered_elements : elt list -> t
of_ordered_elements es
is the set containing precisely the elementses
, which must be listed in order.- raises Invalid_argument
if
es
is not sorted.
val asc_elements : ?where:(elt -> int) -> t -> elt Stdlib.Seq.t
asc_elements ?where s
is the sequence of elements ofe
in ascending order, optionally restricted to a subrange given bywhere
.- parameter where
must be a monotonically increasing function, in which case the returned elements will be the continuous range at which it evaluates to zero.
val dsc_elements : ?where:(elt -> int) -> t -> elt Stdlib.Seq.t
dsc_elements ?where s
is the sequence of elements ofe
in descending order, optionally restricted to a subrange given bywhere
.- parameter where
must be a monotonically increasing function, in which case the returned elements will be the continuous range at which it evaluates to zero.
val search : (elt -> 'a option) -> t -> 'a option
search f s
is the firstf e
fore
ins
which is different fromNone
, orNone
if there is no suche
.
val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a
fold f s
is the composition off e
for eache
ins
applied in order of increasinge
.
val fold_rev : (elt -> 'a -> 'a) -> t -> 'a -> 'a
fold_rev f s
is the composition off e
fore
ins
applied in order of decreasinge
.
val iter : (elt -> unit) -> t -> unit
iter f s
callsf e
for eache
ins
in order of increasing elements.
include S_monadic with type elt := elt and type t := t
val fold_s : (elt -> 'a -> 'a monad) -> t -> 'a -> 'a monad
val iter_s : (elt -> unit monad) -> t -> unit monad
val search_s : (elt -> 'a option monad) -> t -> 'a option monad
val for_all_s : (elt -> bool monad) -> t -> bool monad
val exists_s : (elt -> bool monad) -> t -> bool monad
val filter_s : (elt -> bool monad) -> t -> t monad