// Test driver for index-heap-based priority queue. // Index is just a table of priorities whose // subscripts are used in the PQ. import java.util.Scanner; public class intPQiTest { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.format("Enter table size\n"); int n=sc.nextInt(); int key[]=new int[n]; System.out.format("Enter PQ size\n"); int m=sc.nextInt(); intPQi pq=new intPQi(key,m); for (int i=0;i%d for getmax)\n",n-1); op=sc.nextInt(); if (op<0) break; if (op>=n) if (pq.empty()) System.out.format("Can't do getmax() when pq is empty\n"); else { int i=pq.getmax(); System.out.format("getmax() indicates key[%d]=%d\n",i,key[i]); key[i]=(-1); } else { if (key[op]<0) { if (pq.full()) System.out.format("pq already full\n"); else { int val=(-1); while (val<0) { System.out.format("Enter priority to insert() at slot %d\n",op); val=sc.nextInt(); } key[op]=val; pq.insert(op); } } else { int val=(-1); while (val<0) { System.out.format("Enter priority for change() at slot %d\n",op); val=sc.nextInt(); } key[op]=val; pq.change(op); } } } } }