Interface PriorityQueue

All Known Implementing Classes:
DynamicHeap

public interface PriorityQueue

Generic min-priority queue (smaller priority value = higher priority).


Method Summary
 void decreasePriority(java.lang.Object item, java.lang.Comparable priority)
          Decreases the priority of the given item to the given priority value if the new priority is less than the old, does nothing otherwise.
 java.lang.Object deleteMinPriority()
          Removes the first item with smallest priority value from this queue, and returns this item.
 java.lang.Object getMinPriority()
          Returns the first item with smallest priority value in this queue.
 void insert(java.lang.Object item, java.lang.Comparable priority)
          Adds the given item with the given priority value to this queue.
 boolean isEmpty()
          Returns true if the queue is empty and false otherwise.
 

Method Detail

isEmpty

public boolean isEmpty()
Returns true if the queue is empty and false otherwise.

Returns:
true if the queue is empty, false otherwise.

getMinPriority

public java.lang.Object getMinPriority()
Returns the first item with smallest priority value in this queue. Precondition: this queue is not empty

Returns:
the first item with smallest priority value in this queue
Throws:
java.lang.NullPointerException - if this queue is empty

deleteMinPriority

public java.lang.Object deleteMinPriority()
Removes the first item with smallest priority value from this queue, and returns this item. Precondition: this queue is not empty

Returns:
the first item with smallest priority value in this queue
Throws:
java.lang.NullPointerException - if this queue is empty

insert

public void insert(java.lang.Object item,
                   java.lang.Comparable priority)
Adds the given item with the given priority value to this queue. Precondition: item != null, priority != null

Parameters:
item - the item to add to this queue
priority - the priority value for item
Throws:
java.lang.NullPointerException - if item == null or priority == null

decreasePriority

public void decreasePriority(java.lang.Object item,
                             java.lang.Comparable priority)
Decreases the priority of the given item to the given priority value if the new priority is less than the old, does nothing otherwise. Precondition: item != null, priority != null

Parameters:
item - whose priority will be decreased
priority - the new priority value for item
Throws:
java.lang.NullPointerException - if item == null or priority == null