public interface DoubleComparator
double values.
This is a @FunctionalInterface even though it isn't declared as one,
so that it can be used in Java 6+.
| Modifier and Type | Method and Description |
|---|---|
int |
compare(double d1,
double d2)
Compares
d1 and d2. |
int compare(double d1,
double d2)
d1 and d2. Returns a negative value to indicate
that d1 < d2, 0 to indicate that d1 == d2, and a positive
value to indicate that d1 > d2.
Implementations of this method must maintain the following invariants:
s(compare(x, y)) == -s(compare(y, x))
s(compare(x, y)) == s(compare(y, z)) →
s(compare(x, y)) == s(compare(x, z)) (transitivity)
compare(x, y) == 0 →
s(compare(x, z)) == s(compare(y, z)) ∀ z
where s(x) is defined as follows:
x < 0: -1
x == 0: 0
x > 0: 1
Double.NEGATIVE_INFINITY, and Double.POSITIVE_INFINITY
values. See Double.compareTo(Double) for a valid example.d1 - the first double to compared2 - the second double to compared1 is less than, equal to, or greater than d2,
respectivelyCopyright © 2021. All rights reserved.