public class UnsortedPriorityQueue<K,V> extends AbstractPriorityQueue<K,V>
AbstractPriorityQueue.PQEntry<K,V>| Constructor and Description |
|---|
UnsortedPriorityQueue()
Creates an empty priority queue based on the natural ordering of its keys.
|
UnsortedPriorityQueue(Comparator<K> comp)
Creates an empty priority queue using the given comparator to order keys.
|
| Modifier and Type | Method and Description |
|---|---|
Entry<K,V> |
insert(K key,
V value)
Inserts a key-value pair and returns the entry created.
|
Entry<K,V> |
min()
Returns (but does not remove) an entry with minimal key.
|
Entry<K,V> |
removeMin()
Removes and returns an entry with minimal key.
|
int |
size()
Returns the number of items in the priority queue.
|
checkKey, compare, isEmptypublic UnsortedPriorityQueue()
public UnsortedPriorityQueue(Comparator<K> comp)
comp - comparator defining the order of keys in the priority queuepublic Entry<K,V> insert(K key, V value) throws IllegalArgumentException
key - the key of the new entryvalue - the associated value of the new entryIllegalArgumentException - if the key is unacceptable for this queuepublic Entry<K,V> min()
public Entry<K,V> removeMin()
public int size()