module Cis:sig..end
This module implements compact integer sets, represented as a (custom) list of integer intervals. Usual set operations are provided. The advantage compared to ordered lists is that the actual size may be smaller than the cardinal of a set when many elements are contiguous. Most set operations are linear w.r.t. the size of the structure, not the cardinal of the set.
License: LGPL
Author(s): : Sébastien Ferré <ferre@irisa.fr>
See also Home page
type t
val max_elt : t -> intmax_elt cis returns the maximum integer in cis. Takes constant time.val min_elt : t -> intmin_elt cis returns the minimum integer in cis. Takes linear time.val append : t -> t -> tappend cis1 cis2 returns the union of cis1 and cis2 assuming that all elements of cis1 are greater than any element of cis2.
Takes linear time in the size of cis1. Not tail-recursive.val empty : tempty is the empty set.val is_empty : t -> boolis_empty cis returns whether cis is the empty set.val cardinal : t -> intcardinal cis returns the cardinal of cis. Takes linear time in the size of cis.val mem : int -> t -> boolmem x cis returns whether x belongs to cis. Takes linear time in the size of cis.val singleton : int -> tsingleton x returns a singleton set with element x.val add : int -> t -> tadd x cis adds element x to cis. Takes linear time in the size of cis, but constant time when x is greater than any element in cis.
Not tail-recursive.val remove : int -> t -> tremove x cis removes element x from cis. Not tail-recursive.val of_list : int list -> tof_list l builds a cis from an integer list.val union : t -> t -> tval inter : t -> t -> tval diff : t -> t -> tval subset : t -> t -> boolsubset cis1 cis2 returns whether cis1 is a subset of cis2.val equal : t -> t -> boolequal cis1 cis2 returns whether cis1 is equal to cis2.val iter : (int -> unit) -> t -> unitval fold_left : ('a -> int -> 'a) -> 'a -> t -> 'aval fold_right : (int -> 'a -> 'a) -> t -> 'a -> 'aval elements : t -> int listelements cis returns the elements of cis as list of decreasing integers.