public class PQ { static final boolean DEBUG=false; private InterestingPoint [] a; private int N; private InterestingPoint last=null; public PQ(int max) { a=new InterestingPoint[max+1]; N=0; } public void insert(InterestingPoint v) { if(DEBUG) System.out.println("PQ: Inserting "+v+" at " +(N+1)); a[++N]=v; upheap(N); } public void upheap(int k) { if(DEBUG) System.out.println("PQ: upheap"); InterestingPoint v; v=a[k]; while(k!=1 && a[k/2].ge(v) ) { a[k]=a[k/2]; k=k/2; } if(DEBUG) System.out.println("PQ: element "+v+" ended up at "+k); a[k]=v; } public void downheap(int k) { if(DEBUG) System.out.println("PQ: downheap"); int j; InterestingPoint v=a[k]; while(k<=N/2) { j=k+k; if(j"); for(int i=1;i<=N;i++) { s.append(a[i]+"->"); } return s.toString(); } } // PQ