|
net.datastructures - version 5.0 | |||||||
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.
Nested Class Summary | |
---|---|
protected static class |
SortedListPriorityQueue.MyEntry<K,V>
Inner class for entries |
Field Summary | |
---|---|
protected Position<Entry<K,V>> |
actionPos
|
protected Comparator<K> |
c
|
protected PositionList<Entry<K,V>> |
entries
|
Constructor Summary | |
---|---|
SortedListPriorityQueue()
Creates the priority queue with the default comparator. |
|
SortedListPriorityQueue(Comparator<K> comp)
Creates the priority queue with the given comparator. |
|
SortedListPriorityQueue(PositionList<Entry<K,V>> list,
Comparator<K> comp)
Creates the priority queue with the given comparator and list. |
Method Summary | |
---|---|
protected boolean |
checkKey(K key)
Determines whether a key is valid. |
Entry<K,V> |
insert(K k,
V v)
Inserts a key-value pair and return the entry created. |
protected void |
insertEntry(Entry<K,V> e)
Auxiliary method used for insertion. |
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(Comparator<K> comp)
Sets the comparator for this priority queue. |
int |
size()
Returns the number of elements in the priority queue. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected PositionList<Entry<K,V>> entries
protected Comparator<K> c
protected Position<Entry<K,V>> actionPos
Constructor Detail |
---|
public SortedListPriorityQueue()
public SortedListPriorityQueue(Comparator<K> comp)
public SortedListPriorityQueue(PositionList<Entry<K,V>> list, Comparator<K> comp)
Method Detail |
---|
public void setComparator(Comparator<K> comp) throws IllegalStateException
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
protected void insertEntry(Entry<K,V> e)
public Entry<K,V> removeMin() throws EmptyPriorityQueueException
removeMin
in interface PriorityQueue<K,V>
EmptyPriorityQueueException
protected boolean checkKey(K key) throws InvalidKeyException
InvalidKeyException
public String toString()
toString
in class Object
|
net.datastructures - version 5.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |