module BatISet:sig..end
Sets of integers represented as ranges
This data structure is efficient for large sets of integers where
many adjacent integers are all part of the set. This will have
higher overhead for sets with lots of point elements, but will be
much more efficient for sets containing mostly ranges.
typet =(int * int) BatAvlTree.tree
typeelt =int
val empty : tval is_empty : t -> booltrue if the set is empty.val mem : int -> t -> boolval add : int -> t -> tval add_range : int -> int -> t -> tadd_range lo hi t adds the range of integers lo, hi (including both endpoints) to
the given set, returning a new setInvalid_argument if lo > hival singleton : int -> tval remove : int -> t -> tval remove_range : int -> int -> t -> tremove_range lo hi t removes a range of elements from the given set, returning a new setInvalid_argument if lo > hival union : t -> t -> tval inter : t -> t -> tval diff : t -> t -> tunion and inter, order matters here.val compl : t -> tval compare : t -> t -> intval equal : t -> t -> boolval ord : t -> t -> BatOrd.ordercompare but returns BatOrd.Lt | BatOrd.Eq | BatOrd.Gt
instead of an int.val subset : t -> t -> boolsubset t u returns true if t is a subset of uval from : int -> t -> tfrom x t returns the portion of t in the range x, max_intval after : int -> t -> tafter x t returns the portion of t in the range x+1, max_intval until : int -> t -> tuntil x t returns the portion of t in the range min_int, xval before : int -> t -> tbefore x t returns the portion of t in the range min_int, x-1val iter : (int -> unit) -> t -> unititer f t calls f once for each element of tval iter_range : (int -> int -> unit) -> t -> unititer_range f t calls f once for each contiguous range of t.
The contiguous ranges of a set are sequences of adjacent integers
all part of the set.val fold : (int -> 'a -> 'a) -> t -> 'a -> 'afold f t x0 returns the final result of merging each element of
t into x0 using merge function fval fold_range : (int -> int -> 'a -> 'a) -> t -> 'a -> 'aval for_all : (int -> bool) -> t -> boolval exists : (int -> bool) -> t -> boolval filter : (int -> bool) -> t -> tval partition : (int -> bool) -> t -> t * tval cardinal : t -> intval elements : t -> int listval ranges : t -> (int * int) listval min_elt : t -> intval max_elt : t -> intval choose : t -> intval enum : t -> (int * int) BatEnum.tval of_enum : (int * int) BatEnum.t -> t
val of_list : (int * int) list -> tval print : 'a BatIO.output -> t -> unit