Package org.jgrapht.alg.util
Class ToleranceDoubleComparator
- java.lang.Object
-
- org.jgrapht.alg.util.ToleranceDoubleComparator
-
- All Implemented Interfaces:
java.io.Serializable
,java.util.Comparator<java.lang.Double>
public class ToleranceDoubleComparator extends java.lang.Object implements java.util.Comparator<java.lang.Double>, java.io.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(java.lang.Double o1, java.lang.Double o2)
Compares two floating point values.
-
-
-
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(java.lang.Double o1, java.lang.Double o2)
Compares two floating point values. Returns 0 if they are equal, -1 if o1 < o2, 1 otherwise- Specified by:
compare
in interfacejava.util.Comparator<java.lang.Double>
- Parameters:
o1
- the first valueo2
- the second value- Returns:
- 0 if they are equal, -1 if o1 < o2, 1 otherwise
-
-