Java – what is the time complexity of this sort method?

I wrote this course:

public class SortingObjectsWithAngleField implements Comparator<Point> {

    public int compare(Point p1,Point p2) {
        double delta = p1.getAngle() - p2.getAngle();
        if(delta == 0.00001)
            return 0;
        return (delta > 0.00001) ? 1 : -1;
    }
}

Then in my main () method, I create a list, and I add some objects with "X" and "angle" fields Then I use

Collections.sort(list,new SortingObjectsWithAngleField());

I wonder what is the complexity of this sort?

thank you

Solution

You can read the documents in the collection sort, but this is for you:

Your comparator won't change this complexity unless you do anything with the loop

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>