module type Gen = sig
.. end
type 'a
t
type 'a
bound
Module for simple closed intervals over arbitrary types that are ordered correctly
using polymorphic compare.
val create : 'a bound ->
'a bound -> 'a t
val empty : 'a t
val intersect : 'a t -> 'a t -> 'a t
val is_empty : 'a t -> bool
val is_empty_or_singleton : 'a t -> bool
val bounds : 'a t ->
('a bound * 'a bound) option
val lbound : 'a t -> 'a bound option
val ubound : 'a t -> 'a bound option
val bounds_exn : 'a t ->
'a bound * 'a bound
val lbound_exn : 'a t -> 'a bound
val ubound_exn : 'a t -> 'a bound
val contains : 'a t -> 'a bound -> bool
val compare_value : 'a t ->
'a bound ->
[ `Above | `Below | `Interval_is_empty | `Within ]
val bound : 'a t ->
'a bound -> 'a bound option
bound i x
bounds the value x to the interval i. It returns None if the
interval is empty and Some x' otherwise, where x' is the bounded value.
val is_superset : 'a t -> of_:'a t -> bool
is_superset i1 of_:i2
is whether i1 contains i2. The empty interval is
contained in every interval.
val is_subset : 'a t -> of_:'a t -> bool
val map : f:('a bound -> 'b bound) ->
'a t -> 'b t
val are_disjoint : 'a t list -> bool
Returns true iff a given set of intervals are disjoint
val are_disjoint_as_open_intervals : 'a t list -> bool
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.
val list_intersect : 'a t list ->
'a t list -> 'a t list
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
.
val half_open_intervals_are_a_partition : 'a t list -> bool