You are confusing the type of the data your MinTreeHeap
ought to store with the type of the comparator:
public class MinTreeHeap<T extends DefaultComparator<T>> extends BinaryTree
// ↑ ↑
// | the type to compare
// A type extending the Comparator
Saying that T
shall be both, a Comparator
and the type of the items the Comparator
should compare, makes no sense.
And, the DefaultComparator
expects a type extending Comparable
which your T
type variable does not fulfill.
What you most probably meant is something like this:
public class MinTreeHeap<E, C extends Comparator<E>> extends BinaryTree
implements PriorityQueue<E> {
where E
is the type of the items to store and C
the type of the Comparator
(without forcing it to be a DefaultComparator
.
It is also possible to go without a type variable for the type of the Comparator
:
public class MinTreeHeap<E> extends BinaryTree implements PriorityQueue<E> {
public MinTreeHeap(Comparator<? super E> comp) {
// store comp in a field of type Comparator<? super E>
// or pass it over to other implementation code
…
}
…