ix.isim.util
Interface LongPriorityQueue

All Known Implementing Classes:
TreeOfListsLongPriorityQueue

public interface LongPriorityQueue

This class represents a priority queue, that is a queue in which elements can be held and from which they can be retrieved by priority. For this purpose, each object has a priority associated with it that determines when in relation to the other elements in the queue this element should be retrieved. Priorities are longs here.

If there are several elements in the queue that have the same priority their order can be managed by adding them to the front or the end of the list of elements at that priority. Similarly, retrival can be from the front or the end of the list of elements with the same priority.


Method Summary
 void addElementAtEnd(java.lang.Object object, long priority)
          This function adds the given object at the given priority to this priority queue.
 void addElementAtFront(java.lang.Object object, long priority)
          This function adds the given object at the given priority to this priority queue.
 boolean containsElementAt(java.lang.Object object, long priority)
          This function tests whether the given element is currently in this queue at the given priority.
 java.util.Iterator elements()
          This function returns an iterator of the elements in this priority queue.
 java.lang.Object getHighestEnd()
          This function returns the element in this priority queue that has the highest priority.
 java.lang.Object getHighestFront()
          This function returns the element in this priority queue that has the highest priority.
 java.lang.Object getLowestEnd()
          This function returns the element in this priority queue that has the lowest priority.
 java.lang.Object getLowestFront()
          This function returns the element in this priority queue that has the lowest priority.
 boolean isEmpty()
          This function tests whether this priority queue is empty.
 int length()
          This function returns the size of this priority queue.
 boolean removeElementAt(java.lang.Object object, long priority)
          This function attempts to remove the given object at the given priority from this priority queue.
 java.lang.Object removeHighestEnd()
          This function removes and returns the element in this priority queue that has the highest priority.
 java.lang.Object removeHighestFront()
          This function removes and returns the element in this priority queue that has the highest priority.
 java.lang.Object removeLowestEnd()
          This function removes and returns the element in this priority queue that has the lowest priority.
 java.lang.Object removeLowestFront()
          This function removes and returns the element in this priority queue that has the lowest priority.
 

Method Detail

addElementAtFront

void addElementAtFront(java.lang.Object object,
                       long priority)

This function adds the given object at the given priority to this priority queue. If there are already elements queued at this priority, the new element will be queued at the front.

Parameters:
object - the Object to be added to this LongPriorityQueue
priority - the priority with which the element is to be queued

addElementAtEnd

void addElementAtEnd(java.lang.Object object,
                     long priority)

This function adds the given object at the given priority to this priority queue. If there are already elements queued at this priority, the new element will be queued at the end.

Parameters:
object - the Object to be added to this LongPriorityQueue
priority - the priority with which the element is to be queued

isEmpty

boolean isEmpty()

This function tests whether this priority queue is empty.

Returns:
true if and only if this LongPriorityQueue contains no elements

length

int length()

This function returns the size of this priority queue.

Returns:
the number of elements contained in this LongPriorityQueue

containsElementAt

boolean containsElementAt(java.lang.Object object,
                          long priority)

This function tests whether the given element is currently in this queue at the given priority.

Parameters:
object - the Object to be tested for
priority - the priority at which it should be queued
Returns:
whether it is indeed in the queue

getLowestFront

java.lang.Object getLowestFront()
                                throws java.util.NoSuchElementException

This function returns the element in this priority queue that has the lowest priority. If there are several elements queued at that priority, the element at the front of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the lowest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

getLowestEnd

java.lang.Object getLowestEnd()
                              throws java.util.NoSuchElementException

This function returns the element in this priority queue that has the lowest priority. If there are several elements queued at that priority, the element at the end of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the lowest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

getHighestFront

java.lang.Object getHighestFront()
                                 throws java.util.NoSuchElementException

This function returns the element in this priority queue that has the highest priority. If there are several elements queued at that priority, the element at the front of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the highest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

getHighestEnd

java.lang.Object getHighestEnd()
                               throws java.util.NoSuchElementException

This function returns the element in this priority queue that has the highest priority. If there are several elements queued at that priority, the element at the end of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the highest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

removeLowestFront

java.lang.Object removeLowestFront()
                                   throws java.util.NoSuchElementException

This function removes and returns the element in this priority queue that has the lowest priority. If there are several elements queued at that priority, the element at the front of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the lowest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

removeLowestEnd

java.lang.Object removeLowestEnd()
                                 throws java.util.NoSuchElementException

This function removes and returns the element in this priority queue that has the lowest priority. If there are several elements queued at that priority, the element at the end of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the lowest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

removeHighestFront

java.lang.Object removeHighestFront()
                                    throws java.util.NoSuchElementException

This function removes and returns the element in this priority queue that has the highest priority. If there are several elements queued at that priority, the element at the front of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the highest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

removeHighestEnd

java.lang.Object removeHighestEnd()
                                  throws java.util.NoSuchElementException

This function removes and returns the element in this priority queue that has the highest priority. If there are several elements queued at that priority, the element at the end of the list is retrieved. An exception is thrown if there is no such element, i.e. if this priority queue is empty.

Returns:
the Object that has the highest priority in this LongPriorityQueue
Throws:
java.util.NoSuchElementException - if this LongPriorityQueue is empty

removeElementAt

boolean removeElementAt(java.lang.Object object,
                        long priority)

This function attempts to remove the given object at the given priority from this priority queue. Whether the removal was successful is returned.

Parameters:
object - the Object to be removed from this LongPriorityQueue
priority - the priority at which the element is currently queued
Returns:
true if and only if the object was indeed removed from the queue

elements

java.util.Iterator elements()

This function returns an iterator of the elements in this priority queue.

Returns:
an Iterator for this LongPriorityQueue