Priority queue ordering of elements

后端 未结 4 432
情话喂你
情话喂你 2020-12-18 00:31

How come the elements of priority queue are ordered according to natural order by default as it doesn\'t implement comparable interface.

From the docs, it says elem

4条回答
  •  旧巷少年郎
    2020-12-18 01:03

    The priority queue relies on the following to order the elements:

    • Element must be a Comparable type
    • Need to provide Comparator implementation for the queue

提交回复
热议问题