Interval<T extends Comparable<Object?>> class final

An Interval represents a convex (contiguous) portion of a domain bounded on both ends, i.e. { x | min < x < max }.

T is expected to be immutable. If T is mutable, the value produced by Comparable.compare must not change when used in an Interval. Doing so will result in undefined behaviour.

Inheritance

Constructors

Interval.closed(T min, T max)
Creates an Interval with the closed lower and upper bounds.
Interval.closedOpen(T min, T max)
Creates an Interval with the closed lower bound and open upper bound.
Interval.empty(T value)
Creates an empty Interval with value, i.e. { x | value <= x < value }.
Interval.open(T min, T max)
Creates an Interval with the open lower and upper bounds.
Interval.openClosed(T min, T max)
Creates an Interval with the open lower bound and closed upper bound.

Properties

empty bool
Return true if this is empty, i.e. [a..a).
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
max → ({bool open, T value})
The maximum value and whether the upper bound is open.
final
min → ({bool open, T value})
The minimum value and whether the lower bound is open.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

besides(Range<T> other) bool
Returns true if an empty range exists between this and other.
override
contains(T value) bool
Returns true if this contains value.
override
containsAll(Iterable<T> values) bool
Returns true if this contains all values.
inherited
encloses(Range<T> other) bool
Returns true if other's bounds do not extend outside this bounds.
override
gap(Range<T> other) Interval<T>?
If this does not intersect other, returns the gap in between. Otherwise returns null.
override
intersection(Range<T> other) Interval<T>?
If this intersects other, returns the intersection. Otherwise returns null.
override
intersects(Range<T> other) bool
Returns true if a non-empty range exists between this and other.
override
iterate({required T by(T current), bool ascending = true}) Iterable<T>
Returns a lazy Iterable by stepping through this range using by.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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