module Biocaml_iset: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.
type
t
val empty : t
val is_empty : t -> bool
true
if the set is empty.val mem : t -> int -> bool
val add : t -> int -> t
val add_range : t -> int -> int -> t
add_range t lo hi
adds the range of integers lo, hi
(including both endpoints) to
the given set, returning a new setInvalid_argument
if lo
> hi
val intersects_range : t -> int -> int -> bool
val singleton : int -> t
val remove : t -> int -> t
val remove_range : t -> int -> int -> t
remove_range lo hi t
removes a range of elements from the given set, returning a new setInvalid_argument
if lo
> hi
val union : t -> t -> t
val inter : t -> t -> t
val diff : t -> t -> t
union
and inter
, order matters here.val compl : t -> t
val compare : t -> t -> int
val equal : t -> t -> bool
val subset : t -> t -> bool
subset t u
returns true
if t
is a subset of u
val from : t -> n:int -> t
from ~n t
returns the portion of t
in the range n, max_int
val after : t -> n:int -> t
after ~n t
returns the portion of t
in the range n+1, max_int
val until : t -> n:int -> t
until ~n t
returns the portion of t
in the range min_int, n
val before : t -> n:int -> t
before x t
returns the portion of t
in the range min_int, n-1
val iter : t -> f:(int -> unit) -> unit
iter f t
calls f
once for each element of t
val iter_range : t -> f:(int -> int -> unit) -> unit
iter_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 : t -> init:'a -> f:(int -> 'a -> 'a) -> 'a
fold f t x0
returns the final result of merging each element of
t
into x0
using merge function f
val fold_range : t -> init:'a -> f:(int -> int -> 'a -> 'a) -> 'a
val for_all : t -> f:(int -> bool) -> bool
val exists : t -> f:(int -> bool) -> bool
val filter : t -> f:(int -> bool) -> t
val partition : t -> f:(int -> bool) -> t * t
val cardinal : t -> int
val elements : t -> int list
val ranges : t -> (int * int) list
val min_elt : t -> int
val max_elt : t -> int
val choose : t -> int
val to_stream : t -> (int * int) Stream.t
val of_stream : (int * int) Stream.t -> t
val of_list : (int * int) list -> t