java.lang.Object
org.jgrapht.alg.util.ToleranceDoubleComparator
- All Implemented Interfaces:
Serializable
,Comparator<Double>
A double comparator with adjustable tolerance.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final double
Default tolerance used by the comparator.private final double
private static final long
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct 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
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
DEFAULT_EPSILON
public static final double DEFAULT_EPSILONDefault tolerance used by the comparator.- See Also:
-
epsilon
private final double epsilon
-
-
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
-