PriorityQueue
<Customer> queue
= new PriorityQueue<>();
class Customer implements Comparable<Customer> {
public int num
;
public int fee
;
public Customer(int num
, int fee
) {
this.num
= num
;
this.fee
= fee
;
}
@Override
public int compareTo(Customer o
) {
if(o
.fee
>this.fee
){
return 1;
}else if(o
.fee
<this.fee
){
return -1;
}
return 0;
}
}
转载请注明原文地址:https://tech.qufami.com/read-19000.html