Class Point2DComparator

    • Field Detail

      • m_Ascending

        protected boolean m_Ascending
        whether to compare ascending or descending.
      • m_UseOnlyX

        protected boolean m_UseOnlyX
        whether to only use X for comparison.
    • Constructor Detail

      • Point2DComparator

        public Point2DComparator()
        The default constructor uses comparison by points in ascending manner, using only X.
      • Point2DComparator

        public Point2DComparator​(boolean ascending,
                                 boolean useOnlyX)
        This constructor initializes the comparator either in ascending manner or descending.
        Parameters:
        ascending - if true then the ordering is done in ascending manner, otherwise descending
    • Method Detail

      • compare

        public int compare​(Point2D o1,
                           Point2D o2)
        Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
        Specified by:
        compare in interface Comparator<Point2D>
        Parameters:
        o1 - the first object
        o2 - the second object
        Returns:
        a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.