Main.java

class Main {

   public static void print(STORE str) {
      while (!str.isEmpty()) {
         System.out.println(str.remove());
      };
   }

   public static void main(String[] args) {
      Integer io;
      STORE pqueue = new PQueue(new IntComparer());
      for (int i = 1; i <= 100; i++) {
         io = new Integer(i);
         pqueue.add(io);
      };
      Object[] oa = new Object[100];
      for (int i = 200; i >= 101; i--) {
         io = new Integer(i);
         oa[200-i]=io;
      };
      pqueue.addAll(oa);
      System.out.println("PQueue: "+pqueue); print(pqueue);
   }
}

class IntComparer implements COMPARER {
   public int compare(Object o1, Object o2) {
      int n1 = ((Number)o1).intValue();
      int n2 = ((Number)o2).intValue();

      if (n1<n2) {return 1;};
      if (n1>n2) {return -1;};
      return 0;
   }
}


Part of Priority Queues mit Java
Andreas Podelski, Abdelwaheb Ayari, Hubert Baumeister
February 25, 1997

Imprint | Data Protection