PriorityBlockingQueue
is unbounded, but I need to bound it somehow. What is the best way to achieve that?
For information, the bounded PriorityBlo
There is another implementation here
It seems to do what you are asking for:
A BoundedPriorityQueue implements a priority queue with an upper bound on the number of elements. If the queue is not full, added elements are always added. If the queue is full and the added element is greater than the smallest element in the queue, the smallest element is removed and the new element is added. If the queue is full and the added element is not greater than the smallest element in the queue, the new element is not added.