module type Accessors =sig
..end
include Container.Generic_phantom
type ('a, 'comparator)
tree
type ('a, 'comparator, 'z)
options
val invariants : ('a, 'comparator, ('a, 'comparator) t -> bool)
options
val mem : ('a, 'comparator, ('a, 'comparator) t -> 'a elt -> bool)
options
val add : ('a, 'comparator, ('a, 'comparator) t -> 'a elt -> ('a, 'comparator) t)
options
val remove : ('a, 'comparator, ('a, 'comparator) t -> 'a elt -> ('a, 'comparator) t)
options
val union : ('a, 'comparator,
('a, 'comparator) t -> ('a, 'comparator) t -> ('a, 'comparator) t)
options
val inter : ('a, 'comparator,
('a, 'comparator) t -> ('a, 'comparator) t -> ('a, 'comparator) t)
options
val diff : ('a, 'comparator,
('a, 'comparator) t -> ('a, 'comparator) t -> ('a, 'comparator) t)
options
val compare_direct : ('a, 'comparator, ('a, 'comparator) t -> ('a, 'comparator) t -> int)
options
val equal : ('a, 'comparator, ('a, 'comparator) t -> ('a, 'comparator) t -> bool)
options
subset t1 t2
returns true iff t1
is a subset of t2
.val subset : ('a, 'comparator, ('a, 'comparator) t -> ('a, 'comparator) t -> bool)
options
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 iter2 : ('a, 'comparator,
('a, 'comparator) t ->
('a, 'comparator) t ->
f:([ `Both of 'a elt * 'a elt | `Left of 'a elt | `Right of 'a elt ] -> unit) ->
unit)
options
val filter : ('a, 'comparator,
('a, 'comparator) t -> f:('a elt -> bool) -> ('a, 'comparator) t)
options
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,
('a, 'comparator) t ->
f:('a elt -> bool) -> ('a, 'comparator) t * ('a, 'comparator) t)
options
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,
('a, 'comparator) t ->
'a elt -> ('a, 'comparator) t * bool * ('a, 'comparator) t)
options
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,
('a, 'comparator) t ->
equiv:('a elt -> 'a elt -> bool) -> ('a, 'comparator) t list)
options
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
find_index t i
returns the i
th smallest element of t
in O(log n) time. The
smallest element has i = 0
.val find_index : ('a, 'b) t -> int -> 'a elt option
val remove_index : ('a, 'comparator, ('a, 'comparator) t -> int -> ('a, 'comparator) t)
options
val to_tree : ('a, 'comparator) t -> ('a elt, 'comparator) tree