Interval<T extends Comparable<T>> class

An interval over a continuous ordering of type T.

Contrary to the Range collection, this object includes both the lower and upper endpoint; and provides efficient means to compute the intersection and union between objects.

See https://en.wikipedia.org/wiki/Interval_(mathematics).

Available extensions
Annotations
  • @immutable

Constructors

Interval.new(T lower, [T? upper])
Returns a interval between lower and upper (inclusive): { x ∈ T | lower <= x <= upper }.

Properties

hashCode int
The hash code for this object.
no setteroverride
isSingle bool
Returns true, if this is an interval with a single value.
no setter
lower → T
Returns the upper bound of this interval.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
upper → T
Returns the lower bound of this interval.
final

Methods

contains(T value) bool
Whether value is included in this interval.
encloses(Interval<T> other) bool
Whether this interval completely covers other.
intersection(Interval<T> other) Interval<T>?
Returns the interval where this and other interval overlap. If the intervals do not intersect, return null.
intersects(Interval<T> other) bool
Whether this interval and other overlap.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDuration() Duration

Available on Interval<DateTime>, provided by the DurationIntervalDateTimeExtension extension

Converts an Interval of DateTime objects into a Duration.
toString() String
A string representation of this object.
override
union(Interval<T> other) Interval<T>
Returns the minimal interval enclosing this and other interval.

Operators

operator ==(Object other) bool
The equality operator.
override