ComparableX<T extends Comparable<T> > extension
Range and ordering helpers for any self-comparable type
(String, DateTime, Duration, and your own Comparable types).
Numeric types are excluded by the bound because num already provides
comparison operators and num.clamp.
- on
-
- T
Methods
-
coerceAtLeast(
T min) → T -
Available on T, provided by the ComparableX extension
Returnsminwhen this value sorts before it, otherwise this value. -
coerceAtMost(
T max) → T -
Available on T, provided by the ComparableX extension
Returnsmaxwhen this value sorts after it, otherwise this value. -
coerceIn(
T min, T max) → T -
Available on T, provided by the ComparableX extension
Constrains this value to the inclusive range [min,max]. -
coerceMax(
T other) → T -
Available on T, provided by the ComparableX extension
The larger of this value andother. -
coerceMin(
T other) → T -
Available on T, provided by the ComparableX extension
The smaller of this value andother. -
isInRange(
T min, T max) → bool -
Available on T, provided by the ComparableX extension
Whether this value falls within [min,max] inclusively. -
isInRangeExclusive(
T min, T max) → bool -
Available on T, provided by the ComparableX extension
Whether this value falls strictly betweenminandmax.
Operators
-
operator <(
T other) → bool -
Available on T, provided by the ComparableX extension
Whether this value sorts beforeother. -
operator <=(
T other) → bool -
Available on T, provided by the ComparableX extension
Whether this value sorts beforeotheror is equal to it. -
operator >(
T other) → bool -
Available on T, provided by the ComparableX extension
Whether this value sorts afterother. -
operator >=(
T other) → bool -
Available on T, provided by the ComparableX extension
Whether this value sorts afterotheror is equal to it.