Is there a PriorityQueue implementation with fixed capacity and custom comparator?
How can you say Lucene's doesn't support a custom comparator?
Its abstract and you must implement the abstract method lessThan(T a, T b)
You could use a SortedSet e.g. TreeSet with a custom comparator and remove the smallest when the size reachs N.
Though an old question but it may be helpful to somebody else. You can use minMaxPriorityQueue of Google's Java library guava.
I can't think of a ready-to-use one, but you can check my implementation of this collection with similar requirements.
The difference is the comparator, but if you extend from PriorityQueue
you'll have it. And on each addition check if you haven't reached the limit, and if you have - drop the last item.