-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExtrinsicMinPQ.java
More file actions
23 lines (23 loc) · 1015 Bytes
/
ExtrinsicMinPQ.java
File metadata and controls
23 lines (23 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package bearmaps;
/**
* Priority queue where objects have a priority that is provided
* extrinsically, i.e. are are supplied as an argument during insertion
* and can be changed using the changePriority method.
*/
public interface ExtrinsicMinPQ<T> {
/* Adds an item with the given priority value. Throws an
* IllegalArgumentExceptionb if item is already present.
* You may assume that item is never null. */
void add(T item, double priority);
/* Returns true if the PQ contains the given item. */
boolean contains(T item);
/* Returns the minimum item. Throws NoSuchElementException if the PQ is empty. */
T getSmallest();
/* Removes and returns the minimum item. Throws NoSuchElementException if the PQ is empty. */
T removeSmallest();
/* Returns the number of items in the PQ. */
int size();
/* Changes the priority of the given item. Throws NoSuchElementException if the item
* doesn't exist. */
void changePriority(T item, double priority);
}