public static final class Ordering.NumericOrdering extends Ordering<Number>
Numbers are compared using the comparison methods provided by LuaMathOperators
,
defining the ordering as one based on the ordering of the mathematical values
of the numbers in question.
This class implements the Comparator
interface by imposing a total order
on numbers that differs from the ordering defined by the methods
eq(Number, Number)
, lt(Number, Number)
and le(Number, Number)
:
eq(a, b) == false
and lt(a, b) == false
when a
or b
is NaN;
-0.0
is considered to be lesser than 0.0
,
while eq(-0.0, 0.0) == true
and lt(-0.0, 0.0) == false
.Note that the total ordering imposed by the compare(Number, Number)
is inconsistent with equals.
For proper treatment of NaNs and (float) zero values, use the
Ordering
methods directly.
Ordering.NumericOrdering, Ordering.StringOrdering
Modifier and Type | Method and Description |
---|---|
int |
compare(Number a,
Number b)
Compare the numbers
a and b , yielding an integer that
is negative, zero or positive if a is lesser than, equal to, or greater
than b . |
boolean |
eq(Number a,
Number b)
Returns
true iff a denotes the same mathematical value
as b . |
boolean |
le(Number a,
Number b)
Returns
true iff the mathematical value denoted by a
is lesser than or equal to the mathematical value denoted by b . |
boolean |
lt(Number a,
Number b)
Returns
true iff the mathematical value denoted by a
is lesser than the mathematical value denoted by b . |
isRawEqual, of
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public boolean eq(Number a, Number b)
true
iff a
denotes the same mathematical value
as b
.
Note that since NaN does not denote any mathematical value,
this method returns false
whenever any of its arguments is NaN.
eq
in class Ordering<Number>
a
- first argument, must not be null
b
- second argument, must not be null
true
iff a
and b
denote the same mathematical
valueNullPointerException
- if a
or b
is null
public boolean lt(Number a, Number b)
true
iff the mathematical value denoted by a
is lesser than the mathematical value denoted by b
.
Note that since NaN does not denote any mathematical value,
this method returns false
whenever any of its arguments is NaN.
lt
in class Ordering<Number>
a
- first argument, must not be null
b
- second argument, must not be null
true
iff the mathematical value denoted by a
is lesser than the mathematical value denoted by b
NullPointerException
- if a
or b
is null
public boolean le(Number a, Number b)
true
iff the mathematical value denoted by a
is lesser than or equal to the mathematical value denoted by b
.
Note that since NaN does not denote any mathematical value,
this method returns false
whenever any of its arguments is NaN.
le
in class Ordering<Number>
a
- first argument, must not be null
b
- second argument, must not be null
true
iff the mathematical value denoted by a
is lesser than or equal to the mathematical value denoted
by b
NullPointerException
- if a
or b
is null
public int compare(Number a, Number b)
a
and b
, yielding an integer that
is negative, zero or positive if a
is lesser than, equal to, or greater
than b
.
The ordering imposed by this method differs from the one defined
by the methods eq(Number, Number)
, lt(Number, Number)
and le(Number, Number)
in the treatment of NaNs
and float zeros:
eq(a, b) == false
and lt(a, b) == false
when a
or b
is NaN;
-0.0
is considered to be lesser than 0.0
,
while eq(-0.0, 0.0) == true
and lt(-0.0, 0.0) == false
.The total ordering of Number
objects imposed by this method
is inconsistent with equals.
a
- first argument, must not be null
b
- second argument, must not be null
a
is lesser
than, equal to, or greater than the number b
NullPointerException
- if a
or b
is null
Copyright © 2016. All rights reserved.