My Comparator is currently typed to JobSet
. I'm unsure why it has <capture
- I've never seen that before. Can someone shed some light on what's going on here?
The comparator...
public class JobSetComparator implements Comparator<JobSet> {
@Override
public int compare(JobSet o1, JobSet o2) {
return Integer.compare(o1.getHighestPriority().getValue(), o2.getHighestPriority().getValue());
}
}
The queue...
protected JobSetQueue queue = new JobSetQueue(0, new JobSetComparator());
public JobSetQueue getQueue() {
return queue;
}
public JobSet[] getPrioritizedQueue() {
return Arrays.sort(queue.toArray(), queue.comparator());
}
queue.toArray()
returns a Object[]
, which your provided Comparator
can't handle.
You will need to use the alternate toArray()
, that takes an array of the expected type:
JobSet[] queueArray = queue.toArray(new JobSet[]{});
Arrays.sort(queueArray, queue.comparator());
return queueArray;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With