Class ToleranceDoubleComparator

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:
  • Field Details

    • DEFAULT_EPSILON

      public static final double DEFAULT_EPSILON
      Default tolerance used by the comparator.
      See Also:
  • Constructor Details

    • ToleranceDoubleComparator

      public ToleranceDoubleComparator()
      Construct a new comparator with a DEFAULT_EPSILON tolerance.
    • ToleranceDoubleComparator

      public ToleranceDoubleComparator(double epsilon)
      Construct a new comparator with a specified tolerance.
      Parameters:
      epsilon - the tolerance
  • Method Details

    • 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 interface Comparator<Double>
      Parameters:
      o1 - the first value
      o2 - the second value
      Returns:
      0 if they are equal, -1 if o1 < o2, 1 otherwise