0

このキューを実装して、キーまたは値を使用せずに、それぞれの MyEntry オブジェクトに各インデックス (エントリが ArrayList ヒープにある場所) を保存できるようにする最も簡単な方法は何ですか?

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 + ")";}
}
4

2 に答える 2