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 a DEFAULT_EPSILON tolerance.
    ToleranceDoubleComparator​(double epsilon)
    Construct a new comparator with a specified tolerance.
  • Method Summary

    Modifier and Type Method Description
    int compare​(java.lang.Double o1, java.lang.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 Details

  • Constructor Details

  • Method Details

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