@@ -0,0 +1,1404 @@
+package permafrost.tundra.util.concurrent;%0A%0Aimport java.util.Comparator;%0Aimport java.util.concurrent.PriorityBlockingQueue;%0A%0A/**%0A * A PriotityBlockingQueue with a bounded maximum capacity.%0A *%0A * @param %3CE%3E   The class of items held on this queue.%0A */%0Apublic class BoundedPriorityBlockingQueue%3CE%3E extends PriorityBlockingQueue%3CE%3E %7B%0A    /**%0A     * The maximum capacity of this queue.%0A     */%0A    protected final int capacity;%0A%0A    /**%0A     * Creates a new queue.%0A     *%0A     * @param capacity  The maximum capacity of this queue.%0A     */%0A    public BoundedPriorityBlockingQueue(int capacity) %7B%0A        super(capacity);%0A        this.capacity = capacity;%0A    %7D%0A%0A    /**%0A     * Creates a new queue.%0A     *%0A     * @param capacity      The maximum capacity of this queue.%0A     * @param comparator    The comparator used to compare items in this queue.%0A     */%0A    public BoundedPriorityBlockingQueue(int capacity, Comparator%3C? super E%3E comparator) %7B%0A        super(capacity, comparator);%0A        this.capacity = capacity;%0A    %7D%0A%0A    /**%0A     * Inserts the specified element into this priority queue.%0A     *%0A     * @param item  The item to insert.%0A     * @return      True if the item was inserted, false if queue is at maximum capacity and the item was not inserted.%0A     */%0A    @Override%0A    public boolean offer(E item) %7B%0A        if (size() == capacity) return false;%0A        return super.offer(item);%0A    %7D%0A%7D%0A

Add BoundedPriorityBlockingQueue a blocking priority queue with a maximum capacity