EDU.oswego.cs.dl.util.concurrent
public class BoundedPriorityQueue extends SemaphoreControlledChannel
Put and take operations may throw ClassCastException if elements are not Comparable, or not comparable using the supplied comparator. Since not all elements are compared on each operation it is possible that an exception will not be thrown during insertion of non-comparable element, but will later be encountered during another insertion or extraction.
Field Summary | |
---|---|
protected Heap | heap_ |
Constructor Summary | |
---|---|
BoundedPriorityQueue(int capacity, Comparator cmp)
Create a priority queue with the given capacity and comparator | |
BoundedPriorityQueue(Comparator comparator)
Create a priority queue with the current default capacity
and the given comparator
| |
BoundedPriorityQueue(int capacity)
Create a priority queue with the given capacity,
and relying on natural ordering.
| |
BoundedPriorityQueue()
Create a priority queue with the current default capacity
and relying on natural ordering.
| |
BoundedPriorityQueue(int capacity, Comparator cmp, Class semaphoreClass)
Create a priority queue with the given capacity and comparator, using
the supplied Semaphore class for semaphores. |
Method Summary | |
---|---|
protected Object | extract() |
protected void | insert(Object x) |
Object | peek() |
Throws: IllegalArgumentException if capacity less or equal to zero
Throws: IllegalArgumentException if capacity less or equal to zero NoSuchMethodException If class does not have constructor that intializes permits SecurityException if constructor information not accessible InstantiationException if semaphore class is abstract IllegalAccessException if constructor cannot be called InvocationTargetException if semaphore constructor throws an exception