|
ADS
Algorithms and Data Structures
|
The PRIORITYQUEUE [see PriorityQueue.h] on a list. More...
#include "ADS/Contract.h"#include "ADS/priority/PriorityQueue.h"#include "ADS/sequence/List.h"#include <concepts>#include <cstddef>#include <utility>#include "ADS/priority/impl/ListPriorityQueue.tpp"Go to the source code of this file.
Classes | |
| class | ADS::ListPriorityQueue< T, P, Sorted > |
| a priority queue on a list, sorted by priority if Sorted, unsorted otherwise More... | |
Namespaces | |
| namespace | ADS |
The PRIORITYQUEUE [see PriorityQueue.h] on a list.
ListPriorityQueue is the lists of section 10.1.1: sorted, min() and deleteMin() in \( O( 1 ) \), insert() and decrease() in \( O( n ) \), since the place of an item is found by a scan from the head; unsorted, the other way round, since an item goes to the head and the minimum is found by a scan. The handle is the position of the cell.
The contracts [see Contract.h]: min() and deleteMin() need a queue that is not empty, decrease() a handle of an item of this queue (checked in \( O( n ) \) with the invariants) and a priority not larger than its own; after deleteMin() no item has a smaller priority than the one removed; the invariant is that the list is sorted when it must be and that size() counts its cells. The operations are defined in ListPriorityQueue.tpp.