@FunctionalInterface
public interface AMDistanceComparator<T>
| Modifier and Type | Method and Description |
|---|---|
long |
compare(T value1,
T value2)
Compare the two values, returning a long value representing how far they
are from each other.
|
default java.util.Comparator<T> |
toComparator()
Return a comparator that is equivalent to this
AMDistanceComparator. |
long compare(T value1, T value2)
value1 - the first valuevalue2 - the second valuedefault java.util.Comparator<T> toComparator()
AMDistanceComparator. Implementations of this interface must
use saturated arithmetic, guaranteeing the following conditions:
if amDistanceComparator.compare(a, b) < 0 then
amDistanceComparator.toComparator().compare(a, b) < 0
if amDistanceComparator.compare(a, b) > 0 then
amDistanceComparator.toComparator().compare(a, b) > 0
if amDistanceComparator.compare(a, b) = 0 then
amDistanceComparator.toComparator().compare(a, b) = 0
Comparator equivalent to this
AMDistanceComparator