Package minpq
Interface ExtrinsicMinPQ<T>
- 
- Type Parameters:
- T- the type of elements in this priority queue.
 - All Known Implementing Classes:
- DoubleMapMinPQ,- HeapMinPQ,- OptimizedHeapMinPQ,- UnsortedArrayMinPQ
 
 public interface ExtrinsicMinPQ<T>Priority queue where objects have extrinsic priority. WhilePriorityQueuerelies on objects'Comparable(or aComparatorobject), this interface requires priority values represented asdouble. Cannot contain duplicate or null items.- See Also:
- DoubleMapMinPQ,- UnsortedArrayMinPQ,- HeapMinPQ,- OptimizedHeapMinPQ
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidadd(T item, double priority)Adds an item with the given priority value.voidchangePriority(T item, double priority)Updates the given items' associated priority value.booleancontains(T item)Returns true if the given item is in this priority queue.default booleanisEmpty()Returns true if this priority queue contains no items.TpeekMin()Returns the item with the minimum priority value.TremoveMin()Returns and removes the item with the minimum priority value.intsize()Returns the number of items in this priority queue.
 
- 
- 
- 
Method Detail- 
addvoid add(T item, double priority) Adds an item with the given priority value.- Parameters:
- item- the element to add.
- priority- the priority value for the item.
- Throws:
- IllegalArgumentException- if item is null or already present.
 
 - 
containsboolean contains(T item) Returns true if the given item is in this priority queue.- Parameters:
- item- element to be checked for containment.
- Returns:
- true if the given item is in this priority queue.
 
 - 
peekMinT peekMin() Returns the item with the minimum priority value.- Returns:
- the item with the minimum priority value.
- Throws:
- NoSuchElementException- if this priority queue is empty.
 
 - 
removeMinT removeMin() Returns and removes the item with the minimum priority value.- Returns:
- the item with the minimum priority value.
- Throws:
- NoSuchElementException- if this priority queue is empty.
 
 - 
changePriorityvoid changePriority(T item, double priority) Updates the given items' associated priority value.- Parameters:
- item- the element whose associated priority value should be modified.
- priority- the updated priority value.
- Throws:
- NoSuchElementException- if the item is not present.
 
 - 
sizeint size() Returns the number of items in this priority queue.- Returns:
- the number of elements in this priority queue.
 
 - 
isEmptydefault boolean isEmpty() Returns true if this priority queue contains no items.- Returns:
- true if this priority queue contains no items.
 
 
- 
 
-