Interval
Class INTERVAL [G -> ABSOLUTE]
deals with intervals between two instances of the same class (an actual generic parameter substituting for G
) which conforms to ABSOLUTE
(specifically: DATE
, TIME
, DATE_TIME
).
Creation
The creation procedure make (s, e: G)
takes as arguments two instances of type G
(or G
's actual type from a declaration, e.g., my_time_interval: INTERVAL [TIME]
), which will become the start bound and the end bound of the INTERVAL
. The start bound argument must be "before" the end bound argument (i.e., s <= e
). make
creates twins of its arguments so that the objects referenced as arguments will not change even if the values in the INTERVAL
change.
Interval measurement
The measurement of an interval is done by applying the query duration
. Although the result of duration
will be an instance of class DURATION
, it will be a direct instance of the DURATION
descendant that is appropriate to the actual value of the generic parameter G
. So, for an INTERVAL [TIME]
, the result of duration
will be a direct instance of TIME_DURATION
.
Comparison
-
infix <
andinfix >
compare two intervals on a "strict" basis. This means thatint_1 < int_2
isTrue
ifint_1
starts and ends strictly beforeint_2
. In other words,int_1
must have a start bound less than that ofint_2
and an end bound less than that ofint_2
. -
infix <=
andinfix >=
compare two intervals on a non-strict basis. So,int_1 <= int_2
isTrue
ifint_1
has a start bound less than or equal to that ofint_2
and an end bound less than or equal to that ofint_2
. -
is_equal
(or~
)performs object comparison. -
intersects
is true if one (target)INTERVAL
shares some of the same bounded area with a second (argument)INTERVAL
. -
overlaps
is similar tointersects
with the exception that the argumentINTERVAL
has to be after the targetINTERVAL
.is_overlapped
is the opposite ofoverlaps
. -
meets
andis_met
are used to test whether two intervals have a common bound. -
strict_includes
can be used to test whether the targetINTERVAL
strictly includes the argumentINTERVAL
. So,int_1.strict_includes (int_2)
will beTrue
if the start bound ofint_2
is greater than the start bound ofint_1
and the end bound ofint_2
is less than the end bound ofint_1
.is_strict_included_by
provides the opposite ofstrict_includes
. -
includes
andis_included_by
test for inclusion on a non-strict basis.
Status Report
-
empty
isTrue
if theINTERVAL
is empty, i.e., if the value of the start bound is equal to the value of the end bound. -
has
,strict_before
,strict_after
,before
, andafter
test the position of an element relative to the current interval.
Element change
set_start_bound
and set_end_bound
are available to change the bounds. set_start_bound
and set_end_bound
create new objects from their arguments (twins), so that if these bounds are altered later, the original objects which had been referenced as arguments will not change.
Operations
-
union
provides a newINTERVAL
that includes the entire range covered by both the targetINTERVAL
and an argumentINTERVAL
which intersects the target. -
intersection
returns a newINTERVAL
that represents the area common to both the targetINTERVAL
and the argumentINTERVAL
.intersection
returnsVoid
if the target and argument do not intersect. -
gather
requires that a target and argumentINTERVAL
have a common bound (i.e.,int_1.meets (int_2)
isTrue
) and then returns a newINTERVAL
with the union of the two.