ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ListPriorityQueue.h File Reference

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

Detailed description

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.

See also
A. Montresor, Algoritmi e Strutture Dati, 2025, section 10.1.1, https://algoritmicamente.it/materiali/libro/capitoli/cap10.pdf
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa