In a method I receive a generic object E extends Comparable
as an argument. Now i want to create two priority queues.One which uses the comparato
Your object E
extends java.lang.Comparable,
but it is not a java.util.Comparator
.
Create your first queue w/o a Comparator and you'll get the ordering in your compareTo
function, then create a java.util.Comparator
that does the comparison in reverse (just call a.compareTo(b) and then negate the result) and create your second queue with that comparator.