java.lang.Object
org.jgrapht.alg.util.ToleranceDoubleComparator
- All Implemented Interfaces:
Serializable
,Comparator<Double>
A double comparator with adjustable tolerance.
- Author:
- Dimitrios Michail
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final double
Default tolerance used by the comparator. -
Constructor Summary
ConstructorDescriptionConstruct a new comparator with aDEFAULT_EPSILON
tolerance.ToleranceDoubleComparator
(double epsilon) Construct a new comparator with a specified tolerance. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
DEFAULT_EPSILON
public static final double DEFAULT_EPSILONDefault tolerance used by the comparator.- See Also:
-
-
Constructor Details
-
ToleranceDoubleComparator
public ToleranceDoubleComparator()Construct a new comparator with aDEFAULT_EPSILON
tolerance. -
ToleranceDoubleComparator
public ToleranceDoubleComparator(double epsilon) Construct a new comparator with a specified tolerance.- Parameters:
epsilon
- the tolerance
-
-
Method Details
-
compare
Compares two floating point values. Returns 0 if they are equal, -1 if o1 < o2, 1 otherwise- Specified by:
compare
in interfaceComparator<Double>
- Parameters:
o1
- the first valueo2
- the second value- Returns:
- 0 if they are equal, -1 if o1 < o2, 1 otherwise
-