Package com.zybooks.dsaj.pq
Interface PriorityQueue<K,V>
- Type Parameters:
K
- The key type (keys must be unique and comparable)V
- The value type stored with each entry
- All Known Subinterfaces:
AdaptablePriorityQueue<K,
V>
- All Known Implementing Classes:
AbstractPriorityQueue
,HeapAdaptablePriorityQueue
,HeapPriorityQueue
,SortedPriorityQueue
,UnsortedPriorityQueue
public interface PriorityQueue<K,V>
Interface for the priority queue ADT.
-
Method Summary
Modifier and TypeMethodDescriptionInserts a key-value pair and returns the entry created.boolean
isEmpty()
Tests whether the priority queue is empty.min()
Returns (but does not remove) an entry with minimal key.Removes and returns an entry with minimal key.int
size()
Returns the number of items in the priority queue.
-
Method Details
-
size
int size()Returns the number of items in the priority queue.- Returns:
- number of items
-
isEmpty
boolean isEmpty()Tests whether the priority queue is empty.- Returns:
- true if the priority queue is empty, false otherwise
-
insert
Inserts a key-value pair and returns the entry created.- Parameters:
key
- the key of the new entryvalue
- the associated value of the new entry- Returns:
- the entry storing the new key-value pair
-
min
Returns (but does not remove) an entry with minimal key.- Returns:
- entry having a minimal key (or null if empty)
-
removeMin
Removes and returns an entry with minimal key.- Returns:
- the removed entry (or null if empty)
-