| Online Eiffel Documentation

EiffelStudio

# Interval

Class INTERVAL deals with intervals between two instances of the same class which conform to ABSOLUTE (DATE, TIME, DATE_TIME). The notions of interval is directly linked with the notion of order.

The start_bound must be before the end_bound.

#### Creation

The features make, set_start_bound and set_end_bound take clones of their arguments, so that if these arguments are changed, the interval previously created is not.

It would have been possible to create intervals with references to date or time, but a modification of the dates would have been effective in the interval so that only the invariant would have been able to check if the start_bound is still before the end_bound.

#### Interval measurement

The measure of intervals is made by duration: the result is an instance of the class DURATION. However, as DURATION is the common parent of TIME_DURATION, DATE_DURATION and DATE_TIME_DURATION, it does not have many features available. Some features in class TIME, DATE, DATE_TIME return the same result and are more efficient to use. DURATION has to be use as the last solution.

#### Comparison

It includes intersection, inclusion and a special comparison.

- is_equal is present and compare values, not references.
- Feature intersects returns the mathematical result of the intersection of two intervals.
- is_strict_included_by, strict_includes, is_included_by and includes are connected to the same notion of inclusion.
- <, + > and >= use a special rule to compare intervals. int1 < int2 is true if int1 starts and ends strictly before int2. The other features use the same rule and is_equal if needed.
- overlaps looks like intersects but the argument has to be after the current interval. is_overlapped is the opposite.
- meets and is_met are used to test if two intervals have a common bound.

#### Status Report

The main part of the functions need an argument from the same generic type and return a BOOLEAN value.

- empty tests if the bounds are equal.
- has, strict_before, strict_after, before and after test the position of an element relatively to the current interval.

#### Element change

set_start_bound and set_end_bound are available to change the bounds.

#### Operations

Union and intersection are the mathematical functions. gather requires that two intervals meet each other and then yields the union.