| 51 | } |
| 52 | int top() { assert(count > 0); return q[0]; } |
| 53 | void heapify() { for (int i = count - 1; i > 0; i--) |
| 54 | if (cmp(i, (i - 1) / 2)) swp(i, (i - 1) / 2); } |
| 55 | void update_key(int n) { |
| 56 | assert(loc[n] != -1), swim(loc[n]), sink(loc[n]); } |
| 57 | bool empty() { return count == 0; } |