public
class
PriorityQueue_Java {
static
class
Tuple
implements
Comparable<Tuple>{
int
money;
String name;
public
Tuple(
int
money, String name){
this
.money = money;
this
.name = name;
}
public
String toString(){
return
"["
+ money +
", "
+ name +
"]"
;
}
@Override
public
int
compareTo(Tuple tup) {
return
this
.money - tup.money;
}
}
// --------------------------------------------------------------
static
void
example1(){
System.out.println(
"example1:\n"
);
// push elements into priority queue PQ
PriorityQueue<Tuple> PQ =
new
PriorityQueue<Tuple>();
PQ.add(
new
Tuple(
1500
,
"Alice"
));
PQ.add(
new
Tuple(
850
,
"Bob"
));
System.out.println(
"Content of PQ: "
+ PQ);
}
//-------------------------------------------------------------------
public
static
void
main(String[] args){
example1();
//example2();
//example3();
//example4();
//exercise1();
//exercise2();
}