ahc.collection
Class GenericPriorityQueue

java.lang.Object
  |
  +--ahc.collection.GenericPriorityQueue
All Implemented Interfaces:
PriorityQueue

public class GenericPriorityQueue
extends java.lang.Object
implements PriorityQueue

This is the generic, configurable implementation of a PriorityQueue.

Author:
Arno Haase

Constructor Summary
GenericPriorityQueue(Store store, boolean threadSafe)
           
GenericPriorityQueue(Store store, java.util.Comparator comparator, boolean threadSafe)
           
 
Method Summary
 boolean add(java.lang.Object obj, java.lang.Object priority)
           
 void clear()
           
 void clear(java.lang.Object minPriority)
          removes all elements from the queue that have a lower priority than the specified threshold.
 boolean isEmpty()
           
 boolean isEmpty(java.lang.Object minPriority)
           
 boolean isThreadSafe()
           
 java.lang.Object peek()
          This method is implemented only for non-threadsafe queues so that it does not have InterruptedException in its signature.
 java.lang.Object peek(boolean blocking)
           
 java.lang.Object peek(int timeoutMillis)
           
 java.lang.Object peek(java.lang.Object minPriority)
          same as remove(), but ignores elements of a lower priority than a minimum threshold.
 java.lang.Object peek(java.lang.Object minPriority, boolean blocking)
           
 java.lang.Object peek(java.lang.Object minPriority, int timeoutMillis)
           
 java.lang.Object remove()
          This method is implemented only for non-threadsafe queues so that it does not have InterruptedException in its signature.
 java.lang.Object remove(boolean blocking)
           
 java.lang.Object remove(int timeoutMillis)
           
 java.lang.Object remove(java.lang.Object minPriority)
          same as remove(), but ignores elements of a lower priority than a minimum threshold.
 java.lang.Object remove(java.lang.Object minPriority, boolean blocking)
           
 java.lang.Object remove(java.lang.Object minPriority, int timeoutMillis)
           
 void setAcceptanceThreshold(java.lang.Object o)
          Tells the queue to discard elements that have a lower priority than o.
 int size()
           
 int size(java.lang.Object minPriority)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenericPriorityQueue

public GenericPriorityQueue(Store store,
                            boolean threadSafe)

GenericPriorityQueue

public GenericPriorityQueue(Store store,
                            java.util.Comparator comparator,
                            boolean threadSafe)
Method Detail

add

public boolean add(java.lang.Object obj,
                   java.lang.Object priority)
Specified by:
add in interface PriorityQueue

remove

public java.lang.Object remove()
Description copied from interface: PriorityQueue
This method is implemented only for non-threadsafe queues so that it does not have InterruptedException in its signature. Therefore, this method does not block but rather throws NoSuchElementException if called on an empty queue.

Specified by:
remove in interface PriorityQueue

remove

public java.lang.Object remove(boolean blocking)
                        throws java.lang.InterruptedException
Specified by:
remove in interface PriorityQueue
java.lang.InterruptedException

remove

public java.lang.Object remove(int timeoutMillis)
                        throws java.lang.InterruptedException,
                               TimeoutException
Specified by:
remove in interface PriorityQueue
java.lang.InterruptedException
TimeoutException

remove

public java.lang.Object remove(java.lang.Object minPriority)
Description copied from interface: PriorityQueue
same as remove(), but ignores elements of a lower priority than a minimum threshold.

Specified by:
remove in interface PriorityQueue

remove

public java.lang.Object remove(java.lang.Object minPriority,
                               boolean blocking)
                        throws java.lang.InterruptedException
Specified by:
remove in interface PriorityQueue
java.lang.InterruptedException

remove

public java.lang.Object remove(java.lang.Object minPriority,
                               int timeoutMillis)
                        throws java.lang.InterruptedException,
                               TimeoutException
Specified by:
remove in interface PriorityQueue
java.lang.InterruptedException
TimeoutException

peek

public java.lang.Object peek()
Description copied from interface: PriorityQueue
This method is implemented only for non-threadsafe queues so that it does not have InterruptedException in its signature. Therefore, this method does not block but rather throws NoSuchElementException if called on an empty queue.

Specified by:
peek in interface PriorityQueue

peek

public java.lang.Object peek(boolean blocking)
                      throws java.lang.InterruptedException
Specified by:
peek in interface PriorityQueue
java.lang.InterruptedException

peek

public java.lang.Object peek(int timeoutMillis)
                      throws java.lang.InterruptedException,
                             TimeoutException
Specified by:
peek in interface PriorityQueue
java.lang.InterruptedException
TimeoutException

peek

public java.lang.Object peek(java.lang.Object minPriority)
Description copied from interface: PriorityQueue
same as remove(), but ignores elements of a lower priority than a minimum threshold.

Specified by:
peek in interface PriorityQueue

peek

public java.lang.Object peek(java.lang.Object minPriority,
                             boolean blocking)
                      throws java.lang.InterruptedException
Specified by:
peek in interface PriorityQueue
java.lang.InterruptedException

peek

public java.lang.Object peek(java.lang.Object minPriority,
                             int timeoutMillis)
                      throws java.lang.InterruptedException,
                             TimeoutException
Specified by:
peek in interface PriorityQueue
java.lang.InterruptedException
TimeoutException

size

public int size()
Specified by:
size in interface PriorityQueue

size

public int size(java.lang.Object minPriority)
Specified by:
size in interface PriorityQueue

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface PriorityQueue

isEmpty

public boolean isEmpty(java.lang.Object minPriority)
Specified by:
isEmpty in interface PriorityQueue

clear

public void clear()
Specified by:
clear in interface PriorityQueue

clear

public void clear(java.lang.Object minPriority)
Description copied from interface: PriorityQueue
removes all elements from the queue that have a lower priority than the specified threshold.

Specified by:
clear in interface PriorityQueue

setAcceptanceThreshold

public void setAcceptanceThreshold(java.lang.Object o)
Description copied from interface: PriorityQueue
Tells the queue to discard elements that have a lower priority than o. Passing in "null" clears the acceptance threshold, i.e. all elements are accepted afterwards.

Specified by:
setAcceptanceThreshold in interface PriorityQueue

isThreadSafe

public boolean isThreadSafe()
Specified by:
isThreadSafe in interface PriorityQueue