- java.lang.Object
-
- org.jgrapht.alg.util.ToleranceDoubleComparator
-
- All Implemented Interfaces:
Serializable
,Comparator<Double>
public class ToleranceDoubleComparator extends Object implements Comparator<Double>, Serializable
A double comparator with adjustable tolerance.- Author:
- Dimitrios Michail
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_EPSILON
Default tolerance used by the comparator.
-
Constructor Summary
Constructors Constructor Description ToleranceDoubleComparator()
Construct a new comparator with aDEFAULT_EPSILON
tolerance.ToleranceDoubleComparator(double epsilon)
Construct a new comparator with a specified tolerance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(Double o1, Double o2)
Compares two floating point values.-
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 Detail
-
DEFAULT_EPSILON
public static final double DEFAULT_EPSILON
Default tolerance used by the comparator.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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 Detail
-
compare
public int compare(Double o1, Double o2)
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
- Throws:
NullPointerException
- if either one of the arguments isnull
-
-