Interval

o1.time.Interval
class Interval(val start: Moment, val end: Moment)

Each instance of the class Interval represents an interval — an inclusive range — on a timescale. An interval has a “start moment” and an “end moment”, represented as Moment objects. An interval always contains at least a single moment.

An interval object may be used to represent a range of years, a range of months, etc., as desired

An Interval object is immutable after it has been created. That is, its state can not be changed in any way.

Parameters

end

the end of the interval (that is, the last moment included in the interval); equal to or higher than start

start

the start of the interval (that is, the first moment included in the interval)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def contains(moment: Moment): Boolean

Determines whether the given moment is inside this interval. (An interval also includes its start and end moments.)

Determines whether the given moment is inside this interval. (An interval also includes its start and end moments.)

Attributes

def contains(another: Interval): Boolean

Determines whether this interval contains the given interval. This is the case if and only if all moments within the other interval are contained within this interval.

Determines whether this interval contains the given interval. This is the case if and only if all moments within the other interval are contained within this interval.

Attributes

Creates, and returns a reference to, a new Interval object that represents the intersection of this interval with the given interval. That is, the starting moment of the new interval is the starting moment of one of the two original intervals, whichever is later. Similarly, the end moment of the new interval is the earlier of the two original end moments.

Creates, and returns a reference to, a new Interval object that represents the intersection of this interval with the given interval. That is, the starting moment of the new interval is the starting moment of one of the two original intervals, whichever is later. Similarly, the end moment of the new interval is the earlier of the two original end moments.

However, this method only produces a new interval in case the two original intervals overlap. In that case, the new interval is wrapped inside a Some object. If no intersection exists, ̀ the method returns None instead.

Examples: The intersection of the interval from 1995 to 2003 with the interval from 2000 to 2013 is a new interval from 2000 to 2003. The intersection of the interval from 2000 to 2001 with the interval from 1995 to 1997 does not exist.

Attributes

See also

overlaps

union

def isLaterThan(moment: Moment): Boolean

Determines whether this interval is later than the given moment. This is only deemed to be the case if the entire interval comes after the given moment on the timescale.

Determines whether this interval is later than the given moment. This is only deemed to be the case if the entire interval comes after the given moment on the timescale.

Attributes

def isLaterThan(another: Interval): Boolean

Determines whether this interval is later than the given interval. This is only deemed to be the case if this entire interval comes after the given interval on the timescale. That is, no overlap is allowed.

Determines whether this interval is later than the given interval. This is only deemed to be the case if this entire interval comes after the given interval on the timescale. That is, no overlap is allowed.

Attributes

def length: Int

Returns the length of the interval. For instance, if the interval represents the range of years from 2000 to 2013, returns 13. The length of an interval will always be at least 0 (which is the case if start equals end).

Returns the length of the interval. For instance, if the interval represents the range of years from 2000 to 2013, returns 13. The length of an interval will always be at least 0 (which is the case if start equals end).

Attributes

def overlaps(another: Interval): Boolean

Determines whether this interval overlaps (intersects) the given interval. This is the case if (and only if) one or more of the moments within the other interval are contained within this interval.

Determines whether this interval overlaps (intersects) the given interval. This is the case if (and only if) one or more of the moments within the other interval are contained within this interval.

Note: If one interval is entirely contained within the other, it counts as overlapping, as does the case where one interval ends exactly where the other one begins.

Attributes

override def toString: String

Returns a textual description of the interval. This is a string whose length depends on the length of the interval as follows.

Returns a textual description of the interval. This is a string whose length depends on the length of the interval as follows.

If the length of the interval is 0, returns a string containing just the single moment contained in the interval. E.g., the interval from 2013 to 2013 is represented by the string "2013".

If the length of the interval is above 0 but no more than 50, returns a string consisting of the start moment and the end moment separated by a number of hyphens equal to the length of the interval. For instance, the interval from 2013 to 2014 is represented by the string "2013-2014" and the interval from 2000 to 2013 is represented by the string "2000-------------2013".

If the length of the interval is more than 50, uses three dots instead of hyphens. For instance, the interval from 1900 to 2013 is represented by the string "1900...2013".

Attributes

Definition Classes
Any
def union(another: Interval): Interval

Creates, and returns a reference to, a new Interval object that represents the union of this interval with the given interval. That is, the starting moment of the new interval is the starting moment of one of the two original intervals, whichever is earlier. Similarly, the end moment of the new interval is the later of the two original end moments.

Creates, and returns a reference to, a new Interval object that represents the union of this interval with the given interval. That is, the starting moment of the new interval is the starting moment of one of the two original intervals, whichever is earlier. Similarly, the end moment of the new interval is the later of the two original end moments.

The two original intervals may overlap, but are not required to do so.

Examples: The union of the interval from 1995 to 2003 with the interval from 2000 to 2013 is a new interval from 1995 to 2013. The union of the interval from 2000 to 2001 with the interval from 1995 to 1997 is a new interval from 1995 to 2001.

Attributes

Concrete fields

val end: Moment
val start: Moment