module Interval_intf:sig
..end
module type Gen =sig
..end
module type Gen_set =sig
..end
module type S =sig
..end
module type S1 =sig
..end
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.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.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
.