0
我想要繼承ConcurrentSkipListMap並將它的比較器設爲沒有任何鎖定。 這是我有:如何繼承ConcurrentSkipListMap並設置其比較器?
// the subclass
public class Queue<V, K> extends ConcurrentSkipListMap<K, V> {
public Queue(Comparator<? super K> queueComparator) {
// TODO Auto-generated constructor stub
super(queueComparator);
}
public Queue(QueueComparator<Integer> queueComparator) {
// TODO Auto-generated constructor stub
super((Comparator<? super K>) queueComparator);
}
}
//the comparator (QueueComparator)
public class QueueComparator<T> implements Comparator<T> {
@Override
public int compare(T o1, T o2) {
// TODO Auto-generated method stub
return 0;
}
}
// main class init the subclass
Queue queue= new Queue<Integer,MYCLASS>(new QueueComparator<Integer>());
正如你可以看到我加3層構造到隊列類。無論我在主類中改變了什麼,其他構造函數都會產生錯誤。什麼是正確的方式來設置它的權利? 謝謝