package rangeSet

  1. Overview
  2. Docs

Functor building an implementation of the RangeSet.Discrete structure given a totally ordered type.

Parameters

module Ord : OrderedType

Signature

type t

The type of the sets.

type range = {
  1. start : Ord.t;
  2. stop : Ord.t;
}

The type of the range. A range consists of start and end endpoint.

val range_to_string : range -> string

range_to_string range is the written representation of range.

val to_string : t -> string

to_string set is the written representation of set.

val empty : t

The empty set.

val is_empty : t -> bool

is_empty t tests whether t is empty or not.

val mem : Ord.t -> t -> bool

mem x s tests whether x belongs to the set s.

val add : Ord.t -> t -> t

add x s returns a set containing all elements of s, plus x. If x was already in s, s is returned unchanged.

val singleton : Ord.t -> t

singleton x returns the one-element set containing only x.

val of_point : Ord.t -> Ord.t -> t

of_point p1 p2 returns the set containing a range from p1 to p2.

val of_range : range -> t

of_range r returns the set containing only the range.

val of_ranges : range list -> t

of_ranges rs returns the set containing all the ranges in rs.

val remove : Ord.t -> t -> t

remove x s returns a set containing all elements of s, except x.

val merge : range -> t -> t

merge r s returns a set containing all elements of s , plus range r.

val unmerge : range -> t -> t

unmerge r s returns a set containing all elements of s, except those in range r.

val cover : range -> t -> t

cover r s returns a set containing elements both belongs to range r and set s.

val union : t -> t -> t

Set union.

val diff : t -> t -> t

Set difference: diff s1 s2 contains the elements of s1 that are not in s2.

val inter : t -> t -> t

Set intersection.

val min_elt : t -> Ord.t

Return the smallest element of the given set (with respect to the Ord.compare ordering), or raise Not_found if the set is empty.

val min_elt_opt : t -> Ord.t option

Return the smallest element of the given set (with respect to the Ord.compare ordering), or None if the set is empty.

val max_elt : t -> Ord.t

Return the largest element of the given set (with respect to the Ord.compare ordering), or raise Not_found if the set is empty.

val max_elt_opt : t -> Ord.t option

Return the largest element of the given set (with respect to the Ord.compare ordering), or None if the set is empty.

val iter_elt : (Ord.t -> unit) -> t -> unit

iter_elt f s applies f in turn to all elements of s. The elements of s are presented to f in increasing order with respect to the ordering over the type of the elements.

val map_elt : (Ord.t -> Ord.t) -> t -> t

map_elt f s is the set whose elements are f a0,f a1... f aN, where a0,a1...aN are the elements of s.

The elements are passed to f in increasing order with respect to the ordering over the type of the elements.

val elements : t -> Ord.t list

Return the list of all elements of the given set. The returned list is sorted in increasing order with respect to the ordering Ord.compare, where Ord is the argument given to Discrete.Make.

OCaml

Innovation. Community. Security.