Range<C extends Comparable> class
Notation Definition Factory method
(a..b) {x | a < x < b} open
a..b
{x | a <= x <= b} closed
(a..b] {x | a < x <= b} openClosed
[a..b) {x | a <= x < b} closedOpen
(a..+∞) {x | x > a} greaterThan
a..+∞) {x | x >= a} atLeast
(-∞..b) {x | x < b} lessThan
(-∞..b
{x | x <= b} atMost
(-∞..+∞) {x} all
Properties
- hashCode → int
-
Returns a hash code for this range.
no setteroverride
- hasLowerBound → bool
-
Returns
true
if this range has a lower endpoint.no setter -
lowerBound
→ Cut<
C> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
upperBound
→ Cut<
C> -
final
Methods
-
canonical(
DiscreteDomain< C> domain) → Range<C> - Returns the canonical form of this range in the given domain. The canonical form has the following properties:
-
contains(
C value) → bool -
Returns
true
ifvalue
is within the bounds of this range. For example, on the range[0..2)
,contains(1)
returnstrue
, whilecontains(2)
returnsfalse
. -
containsAll(
Iterable< C> values) → bool - Returns {@code true} if every element in {@code values} is {@linkplain #contains contained} in this range.
-
encloses(
Range< C> other) → bool - Returns {@code true} if the bounds of {@code other} do not extend outside the bounds of this range. Examples:
-
gap(
Range< C> otherRange) → Range<C> - Returns the maximal range lying between this range and {@code otherRange}, if such a range exists. The resulting range may be empty if the two ranges are adjacent but non-overlapping.
-
hasUpperBound(
) → bool - Returns {@code true} if this range has an upper endpoint. */
-
intersection(
Range< C> connectedRange) → Range<C> - Returns the maximal range {@linkplain #encloses enclosed} by both this range and {@code connectedRange}, if such a range exists.
-
isConnected(
Range< C> other) → bool - Returns {@code true} if there exists a (possibly empty) range which is {@linkplain #encloses enclosed} by both this range and {@code other}.
-
isEmpty(
) → bool -
Returns {@code true} if this range is of the form {@code
v..v)} or {@code (v..v
}. (This does not encompass ranges of the form {@code (v..v)}, because such ranges are invalid and can't be constructed at all.) -
lowerBoundType(
) → BoundType - Returns the type of this range's lower bound: {@link BoundType#CLOSED} if the range includes its lower endpoint, {@link BoundType#OPEN} if it does not.
-
lowerEndpoint(
) → C - Returns the lower endpoint of this range.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
span(
Range< C> other) → Range<C> -
Returns the minimal range that {@linkplain #encloses encloses} both this range and {@code
other}. For example, the span of {@code
1..3
} and {@code (5..7)} is {@code [1..7)}. -
toString(
) → String -
A string representation of this object.
override
-
upperBoundType(
) → BoundType - Returns the type of this range's upper bound: {@link BoundType#CLOSED} if the range includes its upper endpoint, {@link BoundType#OPEN} if it does not.
-
upperEndpoint(
) → C - Returns the upper endpoint of this range.
Operators
-
operator ==(
Object object) → bool -
The equality operator.
override
Static Methods
-
all<
C extends Comparable> () → Range< C> - Returns a range that contains every value of type {@code C}.
-
atLeast<
C extends Comparable> (C endpoint) → Range< C> - Returns a range that contains all values greater than or equal to {@code endpoint}.
-
atMost<
C extends Comparable> (C endpoint) → Range< C> - Returns a range that contains all values less than or equal to {@code endpoint}.
-
closed<
C extends Comparable> (C lower, C upper) → Range< C> - Returns a range that contains all values greater than or equal to {@code lower} and less than or equal to {@code upper}.
-
closedOpen<
C extends Comparable> (C lower, C upper) → Range< C> - Returns a range that contains all values greater than or equal to {@code lower} and strictly less than {@code upper}.
-
compareOrThrow(
Comparable left, Comparable right) → int -
create<
C extends Comparable> (Cut< C> lowerBound, Cut<C> upperBound) → Range<C> -
downTo<
C extends Comparable> (C endpoint, BoundType boundType) → Range< C> - Returns a range from the given endpoint, which may be either inclusive (closed) or exclusive (open), with no upper bound.
-
encloseAll<
C extends Comparable> (Iterable< C> values) → Range<C> - Returns the minimal range that {@linkplain Range#contains(Comparable) contains} all of the given values. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
-
greaterThan<
C extends Comparable> (C endpoint) → Range< C> - Returns a range that contains all values strictly greater than {@code endpoint}.
-
lessThan<
C extends Comparable> (C endpoint) → Range< C> - Returns a range that contains all values strictly less than {@code endpoint}.
-
open<
C extends Comparable> (C lower, C upper) → Range< C> - Returns a range that contains all values strictly greater than {@code lower} and strictly less than {@code upper}.
-
openClosed<
C extends Comparable> (C lower, C upper) → Range< C> - Returns a range that contains all values strictly greater than {@code lower} and less than or equal to {@code upper}.
-
range<
C extends Comparable> (C lower, BoundType lowerType, C upper, BoundType upperType) → Range< C> - Returns a range that contains any value from {@code lower} to {@code upper}, where each endpoint may be either inclusive (closed) or exclusive (open).
-
singleton<
C extends Comparable> (C value) → Range< C> - Returns a range that {@linkplain Range#contains(Comparable) contains} only the given value. The returned range is {@linkplain BoundType#CLOSED closed} on both ends.
-
upTo<
C extends Comparable> (C endpoint, BoundType boundType) → Range< C> - Returns a range with no lower bound up to the given endpoint, which may be either inclusive (closed) or exclusive (open).