|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ix.isim.util.TreeOfListsLongPriorityQueue
public class TreeOfListsLongPriorityQueue
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 long
s 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.
The implementation of this priority queue is achieved by maintaining the objects in a sorted tree. The order is determined by the priority and each tree node contains a linked list of all the nodes with the same priority. In this way a reasonably efficient execution of all the operations provided can be guaranteed even for very long queues. Note, however, that the removal of elements from this queue and the contains-test with a given priority is not supported.
Field Summary | |
---|---|
protected LongKeyTreeMap |
pTree
the data structure that contains a tree of lists of nodes |
Constructor Summary | |
---|---|
TreeOfListsLongPriorityQueue()
This constructor creates an empty PriorityQueue. |
|
TreeOfListsLongPriorityQueue(java.lang.Object object,
long priority)
This constructor creates a priority queue with exactly one element, the given object queued at the given 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. |
protected java.lang.Object |
clone()
This class does not support cloning and an Exception will be thrown if this method is called. |
boolean |
containsElementAt(java.lang.Object object,
long priority)
This function throws an UnsupportedOperationException as
there is no efficient implementation of this operation for this class. |
java.util.Iterator |
elements()
This function returns an Iterator for this priority queue. |
boolean |
equals(java.lang.Object obj)
This class does not support equality testing and an exception will be thrown if this method is called. |
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. |
int |
hashCode()
This class does not support hashing and an exception will be thrown if this method is called. |
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 obj,
long p)
This function throws an UnsupportedOperationException as
there is no efficient implementation of this operation for this class. |
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. |
java.lang.String |
toString()
This function creates the printable string representation of this priority queue. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected LongKeyTreeMap pTree
Constructor Detail |
---|
public TreeOfListsLongPriorityQueue()
This constructor creates an empty PriorityQueue.
public TreeOfListsLongPriorityQueue(java.lang.Object object, long priority)
This constructor creates a priority queue with exactly one element, the given object queued at the given priority.
object
- the Object
to be the initial member of this
PriorityQueue
priority
- the priority with which the element is to be queuedMethod Detail |
---|
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
This class does not support cloning and an Exception will be thrown if this method is called.
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- will be thrownpublic 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.
addElementAtFront
in interface LongPriorityQueue
object
- the Object
to be added to this
LongPriorityQueue
priority
- the priority with which the element is to be queuedpublic 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.
addElementAtEnd
in interface LongPriorityQueue
object
- the Object
to be added to this
LongPriorityQueue
priority
- the priority with which the element is to be queuedpublic boolean isEmpty()
This function tests whether this priority queue is empty.
isEmpty
in interface LongPriorityQueue
true
if and only if this PriorityQueue
contains no elementspublic int length()
This function returns the size of this priority queue.
length
in interface LongPriorityQueue
PriorityQueue
public boolean containsElementAt(java.lang.Object object, long priority)
This function throws an UnsupportedOperationException
as
there is no efficient implementation of this operation for this class.
containsElementAt
in interface LongPriorityQueue
object
- Object the element to be tested forpriority
- int the priority at which it should be queued
java.lang.UnsupportedOperationException
- will be thrownpublic 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.
getLowestFront
in interface LongPriorityQueue
Object
that has the lowest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
getLowestEnd
in interface LongPriorityQueue
Object
that has the lowest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
getHighestFront
in interface LongPriorityQueue
Object
that has the highest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
getHighestEnd
in interface LongPriorityQueue
Object
that has the highest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
removeLowestFront
in interface LongPriorityQueue
Object
that has the lowest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
removeLowestEnd
in interface LongPriorityQueue
Object
that has the lowest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
removeHighestFront
in interface LongPriorityQueue
Object
that has the highest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic 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.
removeHighestEnd
in interface LongPriorityQueue
Object
that has the highest priority in this
LongPriorityQueue
java.util.NoSuchElementException
- if this LongPriorityQueue
is
emptypublic boolean removeElementAt(java.lang.Object obj, long p)
This function throws an UnsupportedOperationException
as
there is no efficient implementation of this operation for this class.
removeElementAt
in interface LongPriorityQueue
obj
- the Object
to be removed from this
PriorityQueue
p
- the priority at which the element is queued
java.lang.UnsupportedOperationException
- will be thrownpublic java.util.Iterator elements()
This function returns an Iterator for this priority queue.
elements
in interface LongPriorityQueue
Iterator
for this PriorityQueue
public java.lang.String toString()
This function creates the printable string representation of this priority queue.
toString
in class java.lang.Object
String
representing this
PriorityQueue
public boolean equals(java.lang.Object obj) throws java.lang.UnsupportedOperationException
This class does not support equality testing and an exception will be thrown if this method is called.
equals
in class java.lang.Object
obj
- the Object
object this should be compared to
java.lang.UnsupportedOperationException
- will be thrownpublic int hashCode() throws java.lang.UnsupportedOperationException
This class does not support hashing and an exception will be thrown if this method is called.
hashCode
in class java.lang.Object
java.lang.UnsupportedOperationException
- will be thrown
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |