Order<T> class
abstract
The Order type class is used to define a total ordering
on some type A.
An order is defined by a relation <=, which obeys the following laws:
- either
x <= yory <= x(totality) - if
x <= yandy <= x, thenx == y(antisymmetry) - if
x <= yandy <= z, thenx <= z(transitivity)
The truth table for compare is defined as follows:
| x <= y | x >= y | int | |
|---|---|---|---|
| true | true | = 0 | (corresponds to x == y) |
| true | false | < 0 | (corresponds to x < y) |
| false | true | > 0 | (corresponds to x > y) |
By the totality law, x <= y and y <= x cannot be both false.
- Inheritance
-
- Object
- Eq<
T> - PartialOrder<
T> - Order
Constructors
- Order()
-
const
Properties
Methods
-
and(
Eq< T> eq) → Eq<T> -
Return an
Eqthat gives the result of and ofeq1andeq2.inherited -
between(
T min, T max, T value) → bool -
Test whether
valueis betweenminandmax(inclusive). -
clamp(
T min, T max, T value) → T -
Clamp
valuebetweenminandmax. -
compare(
T x, T y) → int -
Result of comparing
xwithy. Returns an Int whose sign is: -
contramap<
A> (T map(A)) → Order< A> -
Return an Order instance based on a parameter of type
Textracted from a classA.override -
eqv(
T x, T y) → bool -
Returns
trueifx==y,falseotherwise.override -
gt(
T x, T y) → bool -
Returns
trueifx>y,falseotherwise.override -
gteqv(
T x, T y) → bool -
Returns
trueifx>=y,falseotherwise.override -
lt(
T x, T y) → bool -
Returns
trueifx<y,falseotherwise.override -
lteqv(
T x, T y) → bool -
Returns
trueifx<=y,falseotherwise.override -
max(
T x, T y) → T -
If
x > y, returnx, else returny. -
min(
T x, T y) → T -
If
x < y, returnx, else returny. -
neqv(
T x, T y) → bool -
Returns
falseifxandyare equivalent,trueotherwise.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
or(
Eq< T> eq) → Eq<T> -
Return an
Eqthat gives the result of or of this Eq andeq.inherited -
partialCompare(
T x, T y) → double -
Result of comparing
xwithy.override -
toString(
) → String -
A string representation of this object.
inherited
-
xor(
Eq< T> eq) → Eq<T> -
Return an
Eqthat gives the result of xor of this Eq andeq.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
allEqual<
A> () → Order< A> -
An
Orderinstance that considers allAinstances to be equal (comparealways returns0).override -
by<
A, B> (B f(A a), Order< B> ord) → Order<A> -
Convert an implicit
Order<B>to anOrder<A>using the given functionf.override -
from<
A> (int f(A a1, A a2)) → Order< A> -
Define an
Order<A>using the given functionf.override -
fromLessThan<
A> (bool f(A a1, A a2)) → Order< A> -
Define an
Order<A>using the given 'less than' functionf. -
whenEqual<
A> (Order< A> first, Order<A> second) → Order<A> -
Returns a new
Order<A>instance that first compares by the firstOrderinstance and uses the secondOrderinstance to "break ties".