PriorityQueue<int[]> queue = new PriorityQueue<int[]>(new Comparator<int[]>() { public int compare(int[] m, int[] n) { return m[1] - n[1]; } });
class implements Comparable<> 写法:
1 2 3 4 5 6 7
class TeamVotes implements Comparable<TeamVotes> { char team;
public int compareTo(TeamVotes tv) { return this.team - tv.team; } }
Iterate a Map:
1 2 3 4 5 6
Map<Integer, Integer> group = new HashMap<Integer, Integer>(); for (Map.Entry<Integer, Integer> entry : group.entrySet()) { int a = entry.getKey(); int b = entry.getValue(); int keyValue = {entry.getKey(), entry.getValue()}; }