次の問題が発生しました Exception in thread "main" java.lang.ClassCastException: java.lang.ref.SoftReference cannot be cast to java.lang.Comparable
以下のコードで。ご協力ありがとう御座います!
PriorityQueue<SoftReference<Element<K, V>>> heap;
heap.add(new SoftReference<Element<K, V>>(newElement));
クラス要素の定義は次のとおりです
class Element<K, V> implements Comparable<Element<K, V>>{
long timeStamp;
K key;
V val;
@Override
public int compareTo(Element<K, V> o) {
return new Long(timeStamp).compareTo(o.timeStamp);
}
Element(long ts, K key, V val){
this.timeStamp = ts;
this.key = key;
this.val = val;
}
}