public static void main(String[] args) { Queue prioQueue = new SortedListPriorityQueue(NaturalComparator.INSTANCE); /* Random random = new Random(); for(int i=0;i<10;i++){ priorityQueue.enqueue(new Integer(random.nextInt(10)) ); //System.out.println(i); }*/ final String VALUE_A = "A"; final String VALUE_B = "B"; final String VALUE_C = "C"; final String VALUE_D = "D"; final String VALUE_E = "E"; prioQueue.enqueue(VALUE_A); prioQueue.enqueue(VALUE_B); prioQueue.enqueue(VALUE_C); prioQueue.dequeue(); prioQueue.dequeue(); prioQueue.enqueue(VALUE_E); prioQueue.enqueue(VALUE_D); while (!prioQueue.isEmpty()) { System.out.println(prioQueue.dequeue()); } }
public static void main(String[] args) { Queue priorityQueue = new UnsortedListPriorityQueue(NaturalComparator.INSTANCE); Random r = new Random(); for (int i = 0; i < 10; i++) { priorityQueue.enqueue(new Integer(r.nextInt(10))); // System.out.println(i); } while (!priorityQueue.isEmpty()) { System.out.println(priorityQueue.dequeue()); } }