package diet

  1. Overview
  2. Docs
type elt = int64

The type of the set elements

type interval

An interval: a range (x, y) of set values where all the elements from x to y inclusive are in the set

module Interval : sig ... end
type t

The type of sets

val equal : t -> t -> bool

Equality over sets

val compare : t -> t -> int

Comparison over sets

val pp : Format.formatter -> t -> unit

Pretty-print a set

val empty : t

The empty set

val is_empty : t -> bool

Test whether a set is empty or not

val cardinal : t -> elt

cardinal t is the number of elements in the set t

val mem : elt -> t -> bool

mem elt t tests whether elt is in set t

val fold : (interval -> 'a -> 'a) -> t -> 'a -> 'a

fold f t acc folds f across all the intervals in t

val fold_individual : (elt -> 'a -> 'a) -> t -> 'a -> 'a

fold_individual f t acc folds f across all the individual elements of t

val iter : (interval -> unit) -> t -> unit

iter f t iterates f across all the intervals in t

val add : interval -> t -> t

add interval t returns the set consisting of t plus interval

val remove : interval -> t -> t

remove interval t returns the set consisting of t minus interval

val min_elt : t -> interval

min_elt t returns the smallest (in terms of the ordering) interval in t, or raises Not_found if the set is empty.

val max_elt : t -> interval

max_elt t returns the largest (in terms of the ordering) interval in t, or raises Not_found if the set is empty.

val choose : t -> interval

choose t returns one interval, or raises Not_found if the set is empty

val take : t -> elt -> (t * t) option

take n returns Some a, b where cardinal a = n and diff t a = b or None if cardinal t < n

val union : t -> t -> t

set union

val diff : t -> t -> t

set difference

val inter : t -> t -> t

set intersection

val find_next_gap : elt -> t -> elt

find_next_gap from t returns the next element that's absent in set t and greater than or equal to from *

OCaml

Innovation. Community. Security.