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(T lower, [T? upper])
Creates an interval between lower and upper (inclusive): { x ∈ T | lower <= x <= upper }.

Properties

hashCode → int
The hash code for this object.
no setteroverride
isSingle → bool
Whether this interval consists of a single value.
no setter
lower → T
The lower bound of this interval.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
upper → T
The upper bound of this interval.
final

Methods

contains(T value) → bool
Whether value is included in this interval.
difference(Interval<T> other) → List<Interval<T>>
Returns the difference of this interval minus other interval as a list of zero, one, or two disjoint intervals.
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
span(Interval<T> other) → Interval<T>
Returns the minimal interval (convex hull) spanning this and other interval.
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