Class DoubleComparator

  • All Implemented Interfaces:
    java.util.Comparator<java.lang.Double>

    public class DoubleComparator
    extends java.lang.Object
    implements java.util.Comparator<java.lang.Double>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double epsilon  
    • Constructor Summary

      Constructors 
      Constructor Description
      DoubleComparator​(double epsilon)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static boolean closeEnough​(java.lang.Double x, java.lang.Double y, double epsilon)  
      int compare​(java.lang.Double x, java.lang.Double y)  
      private static boolean complexCloseEnough​(double a, double b, double epsilon)
      handles floating point comparison according to http://floating-point-gui.de/errors/comparison/
      boolean equals​(java.lang.Object obj)  
      double getEpsilon()  
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Field Detail

      • epsilon

        private double epsilon
    • Constructor Detail

      • DoubleComparator

        public DoubleComparator​(double epsilon)
    • Method Detail

      • compare

        public int compare​(java.lang.Double x,
                           java.lang.Double y)
        Specified by:
        compare in interface java.util.Comparator<java.lang.Double>
      • getEpsilon

        public double getEpsilon()
      • complexCloseEnough

        private static boolean complexCloseEnough​(double a,
                                                  double b,
                                                  double epsilon)
        handles floating point comparison according to http://floating-point-gui.de/errors/comparison/
      • closeEnough

        private static boolean closeEnough​(java.lang.Double x,
                                           java.lang.Double y,
                                           double epsilon)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Specified by:
        equals in interface java.util.Comparator<java.lang.Double>
        Overrides:
        equals in class java.lang.Object