Implementato HeapAdaptablePriorityQueue mediante heap. Implementato SortedListAdaptablePriorityQueue estendendo SortedListPriorityQueue utilizzando l'interfacciaAdaptablePriorityQueue . L'implementazione di entrambi una una classe LocationAwareEntry estensione di Entry.
This commit is contained in:
@@ -2,6 +2,7 @@ package priorityqueue.heap;
|
||||
import exceptions.EmptyPriorityQueueException;
|
||||
import position.Position;
|
||||
import priorityqueue.Entry;
|
||||
import priorityqueue.MyEntry;
|
||||
import priorityqueue.PriorityQueue;
|
||||
import tree.binarytree.heap.ArrayListCompleteBinaryTree;
|
||||
import tree.binarytree.heap.CompleteBinaryTree;
|
||||
@@ -17,17 +18,7 @@ public class HeapPriorityQueue<K,V> implements PriorityQueue<K,V> {
|
||||
protected Comparator<K> comp;
|
||||
|
||||
|
||||
protected static class MyEntry<K,V> implements Entry<K,V> {
|
||||
protected K key;
|
||||
protected V value;
|
||||
public MyEntry(K k, V v) { key = k; value = v; }
|
||||
public K getKey() { return key; }
|
||||
public V getValue() { return value; }
|
||||
public String toString() { return "(" + key + "," + value + ")"; }
|
||||
}
|
||||
|
||||
|
||||
public HeapPriorityQueue() {
|
||||
public HeapPriorityQueue() {
|
||||
heap = new ArrayListCompleteBinaryTree<Entry<K,V>>();
|
||||
comp = new DefaultComparator<K>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user