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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.