Package minpq
Class UnsortedArrayMinPQ<T>
- java.lang.Object
- 
- minpq.UnsortedArrayMinPQ<T>
 
- 
- Type Parameters:
- T- the type of elements in this priority queue.
 - All Implemented Interfaces:
- ExtrinsicMinPQ<T>
 
 public class UnsortedArrayMinPQ<T> extends Object implements ExtrinsicMinPQ<T> Unsorted array (orArrayList) implementation of theExtrinsicMinPQinterface.- See Also:
- ExtrinsicMinPQ
 
- 
- 
Field SummaryFields Modifier and Type Field Description private List<PriorityNode<T>>itemsListofPriorityNodeobjects representing the item-priority pairs in no specific order.
 - 
Constructor SummaryConstructors Constructor Description UnsortedArrayMinPQ()Constructs an empty instance.
 - 
Method SummaryAll Methods Instance Methods Concrete 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.private intindexOf(T item)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.- 
Methods inherited from class java.lang.Objectclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface minpq.ExtrinsicMinPQisEmpty
 
- 
 
- 
- 
- 
Field Detail- 
itemsprivate final List<PriorityNode<T>> items ListofPriorityNodeobjects representing the item-priority pairs in no specific order.
 
- 
 - 
Method Detail- 
addpublic void add(T item, double priority) Description copied from interface:ExtrinsicMinPQAdds an item with the given priority value.- Specified by:
- addin interface- ExtrinsicMinPQ<T>
- Parameters:
- item- the element to add.
- priority- the priority value for the item.
 
 - 
containspublic boolean contains(T item) Description copied from interface:ExtrinsicMinPQReturns true if the given item is in this priority queue.- Specified by:
- containsin interface- ExtrinsicMinPQ<T>
- Parameters:
- item- element to be checked for containment.
- Returns:
- true if the given item is in this priority queue.
 
 - 
peekMinpublic T peekMin() Description copied from interface:ExtrinsicMinPQReturns the item with the minimum priority value.- Specified by:
- peekMinin interface- ExtrinsicMinPQ<T>
- Returns:
- the item with the minimum priority value.
 
 - 
removeMinpublic T removeMin() Description copied from interface:ExtrinsicMinPQReturns and removes the item with the minimum priority value.- Specified by:
- removeMinin interface- ExtrinsicMinPQ<T>
- Returns:
- the item with the minimum priority value.
 
 - 
changePrioritypublic void changePriority(T item, double priority) Description copied from interface:ExtrinsicMinPQUpdates the given items' associated priority value.- Specified by:
- changePriorityin interface- ExtrinsicMinPQ<T>
- Parameters:
- item- the element whose associated priority value should be modified.
- priority- the updated priority value.
 
 - 
sizepublic int size() Description copied from interface:ExtrinsicMinPQReturns the number of items in this priority queue.- Specified by:
- sizein interface- ExtrinsicMinPQ<T>
- Returns:
- the number of elements in this priority queue.
 
 - 
indexOfprivate int indexOf(T item) 
 
- 
 
-