What is the easiest way for me to implement this queue so that I can save each index (of where the entry is in the ArrayList heap) , in each respective MyEntry object, while not using the key or value to do so?
public class HeapPriorityQueue<K,V> {
protected ArrayList<Entry<K,V>> heap;
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 + ")";}
}
Are you looking for something similiar to this?