|
ADS
Algorithms and Data Structures
|
Two double-ended priority queues of plain items, beyond the book: the best and the worst item by better( a , b ) (\( a \) before \( b \)) both at hand, both removable in \( O( \log n ) \) time. More...
#include "ADS/Contract.h"#include "ADS/priority/OrderKey.h"#include "ADS/sort/Sort.h"#include <bit>#include <cstddef>#include <functional>#include <utility>#include <vector>#include "ADS/priority/impl/MinMaxHeap.tpp"Go to the source code of this file.
Classes | |
| class | ADS::MinMaxHeap< T, Better > |
| a min-max heap of plain items: the best and the worst by better() More... | |
| class | ADS::IntervalHeap< T, Better > |
| an interval heap of plain items: the best and the worst by better() More... | |
Namespaces | |
| namespace | ADS |
Two double-ended priority queues of plain items, beyond the book: the best and the worst item by better( a , b ) (\( a \) before \( b \)) both at hand, both removable in \( O( \log n ) \) time.
A run of removals with no push, as long as an eighth of the items and 64 at least, sorts the items once (by the radix sort for the numbers and the pairs of numbers in the order of std::less or std::greater [see OrderKey.h]), so that the rest of the run takes them from the two ends of the sorted array in \( O( 1 ) \) time each, as a balanced tree does; the next push makes the array a heap again in \( O( n ) \) time (an interval heap straight from the sorted items, the node \( j \) holding the \( j \)-th best and the \( j \)-th worst; a min-max heap by the construction from the bottom up of Atkinson et al.). Both costs are paid by the run, \( O( \log n ) \) amortized per removal.
The contracts [see Contract.h]: min(), max(), popMin() and popMax() need a queue that is not empty; the invariant, checked on queues of at most 1024 items, is the order of the levels (the intervals). The operations are defined in MinMaxHeap.tpp.