ahc.collection
Interface PriorityQueue

All Known Implementing Classes:
GenericPriorityQueue

public interface PriorityQueue

A PriorityQueue is a queue in which all elements have an object signifying its priority; it is up to implementations to specify a valid range of objects and a means of ordering them.

Elements are returned based on their priority, highest priority is returned first. Elements of same priority are returned in the same order they were added.

Author:
Arno Haase

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)
           
 

Method Detail

add

public boolean add(java.lang.Object obj,
                   java.lang.Object priority)

remove

public java.lang.Object remove()
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.


remove

public java.lang.Object remove(boolean blocking)
                        throws java.lang.InterruptedException
java.lang.InterruptedException

remove

public java.lang.Object remove(int timeoutMillis)
                        throws java.lang.InterruptedException,
                               TimeoutException
java.lang.InterruptedException
TimeoutException

remove

public java.lang.Object remove(java.lang.Object minPriority)
same as remove(), but ignores elements of a lower priority than a minimum threshold.


remove

public java.lang.Object remove(java.lang.Object minPriority,
                               boolean blocking)
                        throws java.lang.InterruptedException
java.lang.InterruptedException

remove

public java.lang.Object remove(java.lang.Object minPriority,
                               int timeoutMillis)
                        throws java.lang.InterruptedException,
                               TimeoutException
java.lang.InterruptedException
TimeoutException

peek

public java.lang.Object peek()
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.


peek

public java.lang.Object peek(boolean blocking)
                      throws java.lang.InterruptedException
java.lang.InterruptedException

peek

public java.lang.Object peek(int timeoutMillis)
                      throws java.lang.InterruptedException,
                             TimeoutException
java.lang.InterruptedException
TimeoutException

peek

public java.lang.Object peek(java.lang.Object minPriority)
same as remove(), but ignores elements of a lower priority than a minimum threshold.


peek

public java.lang.Object peek(java.lang.Object minPriority,
                             boolean blocking)
                      throws java.lang.InterruptedException
java.lang.InterruptedException

peek

public java.lang.Object peek(java.lang.Object minPriority,
                             int timeoutMillis)
                      throws java.lang.InterruptedException,
                             TimeoutException
java.lang.InterruptedException
TimeoutException

size

public int size()

size

public int size(java.lang.Object minPriority)

isEmpty

public boolean isEmpty()

isEmpty

public boolean isEmpty(java.lang.Object minPriority)

clear

public void clear()

clear

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


setAcceptanceThreshold

public void setAcceptanceThreshold(java.lang.Object o)
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.


isThreadSafe

public boolean isThreadSafe()