Is there a PriorityQueue implementation with fixed capacity and custom comparator?

后端 未结 9 2509
后悔当初
后悔当初 2020-11-28 05:59

Related questions:

  • Java PriorityQueue with fixed size
  • How do I use a PriorityQueue?
  • get indexes of n smallest elements in an array
9条回答
  •  鱼传尺愫
    2020-11-28 06:46

    You could use a SortedSet e.g. TreeSet with a custom comparator and remove the smallest when the size reachs N.

提交回复
热议问题