public boolean hasNext() {
   return !copy.isEmpty();
 }
 public Integer next() {
   if (!hasNext()) throw new NoSuchElementException();
   return copy.delMin();
 }
 // add all elements to copy of heap
 // takes linear time since already in heap order so no keys move
 public HeapIterator() {
   copy = new IndexMinPQ<Key>(pq.length - 1);
   for (int i = 1; i <= N; i++) copy.insert(pq[i], keys[pq[i]]);
 }