Is Comparator a type class?

后端 未结 3 884
野趣味
野趣味 2021-02-08 02:55

I\'ve been reading up on type classes in Scala and thought I had a good grasp on it, until I remembered Java\'s java.util.Comparator.

If I understand proper

3条回答
  •  无人共我
    2021-02-08 03:23

    No java.util.Comparator is an interface

    public interface Comparator
    

    A comparison function, which imposes a total ordering on some collection of objects. Comparators can be passed to a sort method (such as Collections.sort or Arrays.sort) to allow precise control over the sort order. Comparators can also be used to control the order of certain data structures (such as sorted sets or sorted maps), or to provide an ordering for collections of objects that don't have a natural ordering.

提交回复
热议问题