public class RealComparator extends Object implements Comparator<Double>
TreeSet<Double> and other tools which normally require equals().
epsilon is initially set to zero, so only exact equality matches| Constructor and Description |
|---|
RealComparator(double eps) |
| Modifier and Type | Method and Description |
|---|---|
int |
compare(Double d0,
Double d1)
if Math.abs(d0-d1) <= epsilon
return -1 if either arg is null
|
void |
setEpsilon(double epsilon)
set the tolerance
negative values are converted to positive
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcomparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongpublic int compare(Double d0, Double d1)
compare in interface Comparator<Double>public void setEpsilon(double epsilon)
epsilon - Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.