public boolean hasNext() { return !copy.isEmpty(); }
public Integer next() { if (!hasNext()) throw new NoSuchElementException(); return copy.delMin(); }
public HeapIterator() { copy = new IndexMinPQ<Key>(pq.length - 1); for (int i = 1; i <= N; i++) copy.insert(pq[i], keys[pq[i]]); }