public class HeapAdaptablePriorityQueue<K,V> extends HeapPriorityQueue<K,V> implements AdaptablePriorityQueue<K,V>
HeapPriorityQueue| Modifier and Type | Class and Description |
|---|---|
protected static class |
HeapAdaptablePriorityQueue.LocationAwareEntry<K,V>
Inner class for a location-aware entry.
|
HeapPriorityQueue.MyEntry<K,V>comp, heap| Constructor and Description |
|---|
HeapAdaptablePriorityQueue()
Creates an empty heap with a default comparator.
|
HeapAdaptablePriorityQueue(java.util.Comparator comp)
Creates an empty heap with the given comparator.
|
| Modifier and Type | Method and Description |
|---|---|
protected HeapAdaptablePriorityQueue.LocationAwareEntry<K,V> |
checkEntry(Entry<K,V> ent)
Check whether a given entry is valid.
|
protected HeapAdaptablePriorityQueue.LocationAwareEntry<K,V> |
getEntry(Position p)
Returns the entry stored at a heap node.
|
Entry<K,V> |
insert(K k,
V v)
Inserts a key-value pair and returns the entry created.
|
Entry<K,V> |
remove(Entry<K,V> entry)
Removes and returns the given entry from the heap.
|
protected Position |
replaceEntry(Position v,
HeapAdaptablePriorityQueue.LocationAwareEntry<K,V> e)
Replaces the element of the given position with the given
location-aware entry.
|
K |
replaceKey(Entry<K,V> entry,
K k)
Replaces the key of the given entry.
|
V |
replaceValue(Entry<K,V> e,
V value)
Replaces the value of the given entry.
|
protected void |
swap(Position<Entry<K,V>> u,
Position<Entry<K,V>> v)
Swaps the elements of the two positions.
|
checkKey, downHeap, isEmpty, min, removeMin, setComparator, size, toString, upHeapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisEmpty, min, removeMin, sizepublic HeapAdaptablePriorityQueue()
public HeapAdaptablePriorityQueue(java.util.Comparator comp)
public Entry<K,V> insert(K k, V v) throws InvalidKeyException
insert in interface PriorityQueue<K,V>insert in class HeapPriorityQueue<K,V>InvalidKeyExceptionpublic Entry<K,V> remove(Entry<K,V> entry) throws InvalidEntryException
remove in interface AdaptablePriorityQueue<K,V>InvalidEntryExceptionpublic K replaceKey(Entry<K,V> entry, K k) throws InvalidEntryException
replaceKey in interface AdaptablePriorityQueue<K,V>InvalidEntryExceptionpublic V replaceValue(Entry<K,V> e, V value) throws InvalidEntryException
replaceValue in interface AdaptablePriorityQueue<K,V>InvalidEntryExceptionprotected void swap(Position<Entry<K,V>> u, Position<Entry<K,V>> v)
swap in class HeapPriorityQueue<K,V>protected Position replaceEntry(Position v, HeapAdaptablePriorityQueue.LocationAwareEntry<K,V> e)
protected HeapAdaptablePriorityQueue.LocationAwareEntry<K,V> getEntry(Position p)
protected HeapAdaptablePriorityQueue.LocationAwareEntry<K,V> checkEntry(Entry<K,V> ent) throws InvalidEntryException
InvalidEntryException