module type Accessors =sig
..end
include Container.Generic_phantom
val mem : ('a, 'b) t -> 'a elt -> bool
val add : ('a, 'comparator) t -> 'a elt -> ('a, 'comparator) t
val remove : ('a, 'comparator) t -> 'a elt -> ('a, 'comparator) t
val union : ('a, 'comparator) t -> ('a, 'comparator) t -> ('a, 'comparator) t
val inter : ('a, 'comparator) t -> ('a, 'comparator) t -> ('a, 'comparator) t
val diff : ('a, 'comparator) t -> ('a, 'comparator) t -> ('a, 'comparator) t
val compare : ('a, 'comparator) t -> ('a, 'comparator) t -> int
val equal : ('a, 'comparator) t -> ('a, 'comparator) t -> bool
val subset : ('a, 'comparator) t -> ('a, 'comparator) t -> bool
val fold_until : ('a, 'c) t ->
init:'b -> f:('b -> 'a elt -> [ `Continue of 'b | `Stop of 'b ]) -> 'b
val fold_right : ('a, 'c) t -> init:'b -> f:('a elt -> 'b -> 'b) -> 'b
val filter : ('a, 'comparator) t -> f:('a elt -> bool) -> ('a, 'comparator) t
res = partition_tf set ~f
then fst res
are the elements on which f
produced true
, and snd res
are the elements on which f
produces false
val partition_tf : ('a, 'comparator) t ->
f:('a elt -> bool) -> ('a, 'comparator) t * ('a, 'comparator) t
val elements : ('a, 'b) t -> 'a elt list
val min_elt : ('a, 'b) t -> 'a elt option
val min_elt_exn : ('a, 'b) t -> 'a elt
val max_elt : ('a, 'b) t -> 'a elt option
val max_elt_exn : ('a, 'b) t -> 'a elt
val choose : ('a, 'b) t -> 'a elt option
val choose_exn : ('a, 'b) t -> 'a elt
val split : ('a, 'comparator) t ->
'a elt -> ('a, 'comparator) t * bool * ('a, 'comparator) t
split x set
produces a triple triple
where fst3 triple
is the set of elements
strictly less than x
, snd3 triple
= mem set x
, and trd3 triple
is the set of
elements strictly larger than x
.val group_by : ('a, 'comparator) t ->
equiv:('a elt -> 'a elt -> bool) -> ('a, 'comparator) t list
equiv
is an equivalence predicate, then group_by set ~equiv
produces a list
of equivalence classes (i.e., a set-theoretic quotient). E.g.,
let chars = Set.of_list ['A'; 'a'; 'b'; 'c'] in
let equiv c c' = Char.equal (Char.uppercase c) (Char.uppercase c') in
group_by chars ~equiv
produces
Set.of_list['A';'a']; Set.singleton 'b'; Set.singleton 'c'
Runs in O(n^2) time.
val find_exn : ('a, 'b) t -> f:('a elt -> bool) -> 'a elt
val find_index : ('a, 'b) t -> int -> 'a elt option
val remove_index : ('a, 'comparator) t -> int -> ('a, 'comparator) t
type ('a, 'comparator)
tree
tree t
returns the underlying binary tree that represents the set. This is useful
if you want to marshal a set between processes. Since the set contains a closure,
it cannot be marshalled between processes that use different executables; however,
the underlying tree can.val to_tree : ('a, 'comparator) t -> ('a elt, 'comparator) tree