|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.datastructures.SortedListPriorityQueue<K,V>
public class SortedListPriorityQueue<K,V>
Realization of a priority queue by means of a sorted node list in nondecreasing order.
Constructor Summary | |
---|---|
SortedListPriorityQueue()
Creates the priority queue with the default comparator. |
|
SortedListPriorityQueue(java.util.Comparator<K> comp)
Creates the priority queue with the given comparator. |
|
SortedListPriorityQueue(PositionList<Entry<K,V>> list,
java.util.Comparator<K> comp)
Creates the priority queue with the given comparator and list. |
Method Summary | |
---|---|
Entry<K,V> |
insert(K k,
V v)
Inserts a key-value pair and return the entry created. |
boolean |
isEmpty()
Returns whether the priority queue is empty. |
Entry<K,V> |
min()
Returns but does not remove an entry with minimum key. |
Entry<K,V> |
removeMin()
Removes and returns an entry with minimum key. |
void |
setComparator(java.util.Comparator<K> comp)
Sets the comparator for this priority queue. |
int |
size()
Returns the number of elements in the priority queue. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SortedListPriorityQueue()
public SortedListPriorityQueue(java.util.Comparator<K> comp)
public SortedListPriorityQueue(PositionList<Entry<K,V>> list, java.util.Comparator<K> comp)
Method Detail |
---|
public void setComparator(java.util.Comparator<K> comp) throws java.lang.IllegalStateException
java.lang.IllegalStateException
- if priority queue is not emptypublic int size()
size
in interface PriorityQueue<K,V>
public boolean isEmpty()
isEmpty
in interface PriorityQueue<K,V>
public Entry<K,V> min() throws EmptyPriorityQueueException
min
in interface PriorityQueue<K,V>
EmptyPriorityQueueException
public Entry<K,V> insert(K k, V v) throws InvalidKeyException
insert
in interface PriorityQueue<K,V>
InvalidKeyException
public Entry<K,V> removeMin() throws EmptyPriorityQueueException
removeMin
in interface PriorityQueue<K,V>
EmptyPriorityQueueException
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |