Module Interval_intf

module Interval_intf: sig .. end
Module for simple closed intervals over arbitrary types that are ordered correctly using polymorphic compare.

module type Gen = sig .. end
module type Gen_set = sig .. end
module type S = sig .. end
module type S1 = sig .. end

Module for simple closed intervals over arbitrary types that are ordered correctly using polymorphic compare.

create l u returns the interval with lower bound l and upper bound u, unless l > u, in which case create returns the empty interval.

convex_hull ts returns an interval whose upperbound is the greatest upperbound of the intervals in the list, and whose lowerbound is the least lowerbound of the list.

bound t x returns None iff is_empty t. If bounds t = Some (a, b), then bound returns Some y where y is the element of t closest to x. I.e.:

| y = a if x < a | y = x if a <= x <= b | y = b if x > b

is_superset i1 of_:i2 is whether i1 contains i2. The empty interval is contained in every interval.

map t ~f returns create (f l) (f u) if bounds t = Some (l, u), and empty if t is empty. Note that if f l > f u, the result of map is empty, by the definition of create.

If one thinks of an interval as a set of points, rather than a pair of its bounds, then map is not the same as the usual mathematical notion of mapping f over that set. For example, ~f:(fun x -> x * x) maps the interval

[-1,1]
to
[1,1]
     
, not to
[0,1]
.

are_disjoint ts returns true iff the intervals in ts are pairwise disjoint.

Returns true iff a given set of intervals would be disjoint if considered as open intervals. i.e., (3,4) and (4,5) would count as disjoint.

Assuming that ilist1 and ilist2 are lists of (disjoint) intervals, list_intersect ilist1 ilist2 returns the list of disjoint intervals that correspond to the intersection of ilist1 with ilist2.