diff options
| author | Markus Himmel <markus@himmel-villmar.de> | 2018-05-21 21:05:36 +0200 |
|---|---|---|
| committer | Markus Himmel <markus@himmel-villmar.de> | 2018-05-21 21:05:36 +0200 |
| commit | b8dc20e2a9be3fc3053885a557c23bda8833a670 (patch) | |
| tree | 470d15c126cffc2f466dffb3dbeb949f39a55694 /datastructures/stlPQ.cpp | |
| parent | ad25c63e9eb95cea1dab855bfc93ce7ec0754833 (diff) | |
Remove Skew Heaps and add STL PQs
Diffstat (limited to 'datastructures/stlPQ.cpp')
| -rw-r--r-- | datastructures/stlPQ.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/datastructures/stlPQ.cpp b/datastructures/stlPQ.cpp new file mode 100644 index 0000000..1de4abf --- /dev/null +++ b/datastructures/stlPQ.cpp @@ -0,0 +1,14 @@ +#include <ext/pb_ds/priority_queue.hpp> +template<typename T> +using priorityQueue = __gnu_pbds::priority_queue<T, less<T>>; // greater<T> für Min-Queue + +int main() { + priorityQueue<int> pq; + auto it = pq.push(5); // O(1) + pq.push(7); + pq.pop(); // O(log n) amortisiert + pq.modify(it, 6); // O(log n) amortisiert + pq.erase(it); // O(log n) amortisiert + priorityQueue<int> pq2; + pq.join(pq2); // O(1) +} |
