|
|||||||||
| Home >> All >> org >> ematgine >> utils >> [ concurrent overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.ematgine.utils.concurrent
Class BoundedPriorityQueue

java.lang.Objectorg.ematgine.utils.concurrent.SemaphoreControlledChannel
org.ematgine.utils.concurrent.BoundedPriorityQueue
- All Implemented Interfaces:
- BoundedChannel, Channel, Puttable, Takable
- public class BoundedPriorityQueue
- extends SemaphoreControlledChannel
A heap-based priority queue, using semaphores for concurrency control. The take operation returns the least element with respect to the given ordering. (If more than one element is tied for least value, one of them is arbitrarily chosen to be returned -- no guarantees are made for ordering across ties.) Ordering follows the JDK1.2 collection conventions: Either the elements must be Comparable, or a Comparator must be supplied. Comparison failures throw ClassCastExceptions during insertions and extractions. The implementation uses a standard array-based heap algorithm, as described in just about any data structures textbook.
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.
[ Introduction to this package. ]
| Field Summary | |
protected Heap |
heap_
|
| Fields inherited from class org.ematgine.utils.concurrent.SemaphoreControlledChannel |
capacity_, putGuard_, takeGuard_ |
| Constructor Summary | |
BoundedPriorityQueue()
Create a priority queue with the current default capacity and relying on natural ordering. |
|
BoundedPriorityQueue(java.util.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(int capacity,
java.util.Comparator cmp)
Create a priority queue with the given capacity and comparator |
|
BoundedPriorityQueue(int capacity,
java.util.Comparator cmp,
java.lang.Class semaphoreClass)
Create a priority queue with the given capacity and comparator, using the supplied Semaphore class for semaphores. |
|
| Method Summary | |
protected java.lang.Object |
extract()
Internal mechanics of take. |
protected void |
insert(java.lang.Object x)
Internal mechanics of put. |
java.lang.Object |
peek()
Return, but do not remove object at head of Channel, or null if it is empty. |
| Methods inherited from class org.ematgine.utils.concurrent.SemaphoreControlledChannel |
capacity, offer, poll, put, size, take |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
heap_
protected final Heap heap_
| Constructor Detail |
BoundedPriorityQueue
public BoundedPriorityQueue(int capacity,
java.util.Comparator cmp)
throws java.lang.IllegalArgumentException
- Create a priority queue with the given capacity and comparator
BoundedPriorityQueue
public BoundedPriorityQueue(java.util.Comparator comparator)
- Create a priority queue with the current default capacity
and the given comparator
BoundedPriorityQueue
public BoundedPriorityQueue(int capacity)
- Create a priority queue with the given capacity,
and relying on natural ordering.
BoundedPriorityQueue
public BoundedPriorityQueue()
- Create a priority queue with the current default capacity
and relying on natural ordering.
BoundedPriorityQueue
public BoundedPriorityQueue(int capacity,
java.util.Comparator cmp,
java.lang.Class semaphoreClass)
throws java.lang.IllegalArgumentException,
java.lang.NoSuchMethodException,
java.lang.SecurityException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
- Create a priority queue with the given capacity and comparator, using
the supplied Semaphore class for semaphores.
| Method Detail |
insert
protected void insert(java.lang.Object x)
- Description copied from class:
SemaphoreControlledChannel - Internal mechanics of put.
- Specified by:
insertin classSemaphoreControlledChannel
extract
protected java.lang.Object extract()
- Description copied from class:
SemaphoreControlledChannel - Internal mechanics of take.
- Specified by:
extractin classSemaphoreControlledChannel
peek
public java.lang.Object peek()
- Description copied from interface:
Channel - Return, but do not remove object at head of Channel,
or null if it is empty.
|
|||||||||
| Home >> All >> org >> ematgine >> utils >> [ concurrent overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC