Sorry for the confusion. That is a good suspicion. I had it too. I really did not check compareTo(). I tested compareToXY() .
In the code
public static Comparator<Point> xyPointComparator = new Comparator<Point>() {
@Override
public int compare(Point p1, Point p2)
{
int cmp = p1.compareToXY(p2);
return cmp;
}
There were some lines I removed. It used to look like this:
public static Comparator<Point> xyPointComparator = new Comparator<Point>() {
@Override
public int compare(Point p1, Point p2)
{
int cmp = p1.compareToXY(p2);
int cmp2 = p2.compareToXY(p1);
if (cmp != -cmp2)
{
System.err.println("xyPointComparator comparable violates contract for p1 " + p1 + " p2 " + p2);
}
return cmp;
}
This produced no errors for the data set for either TreeSet or TimSort.