FileDocCategorySizeDatePackage
PriorityQueueTest.javaAPI DocExample789Mon Nov 13 12:14:48 GMT 2006collections

PriorityQueueTest

public class PriorityQueueTest extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    final int INITIAL_CAPACITY = 10;
    Comparator<PriorityTask> priorityComp = new Comparator<PriorityTask>() {
      public int compare(PriorityTask o1, PriorityTask o2) {
        return o1.getPriority().compareTo(o2.getPriority());
      }
    };
    Queue<PriorityTask> priorityQueue =
            new PriorityQueue<PriorityTask>(INITIAL_CAPACITY, priorityComp);
    priorityQueue.add(new PriorityTask(mikePhone, Priority.MEDIUM));
    priorityQueue.add(new PriorityTask(paulPhone, Priority.HIGH));

    PriorityTask nextTask = priorityQueue.poll();