for (Event e : pq)
doesn\'t iterate in the priority order.
while(!pq.isEmpty()){
Event e = pq.poll();
}
This wo
A heap based priority queue only guarantees that the first element is the highest/lowest. There is no cheap (i.e. O(n)) way to get the elements in sorted form.
If you need to do this often, consider using a structure that maintains the elements in sorted form. For example, use java.util.TreeSet, and use either pollFirst() or pollLast() in place of peek() / poll()