From b8dc20e2a9be3fc3053885a557c23bda8833a670 Mon Sep 17 00:00:00 2001 From: Markus Himmel Date: Mon, 21 May 2018 21:05:36 +0200 Subject: Remove Skew Heaps and add STL PQs --- datastructures/stlPQ.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 datastructures/stlPQ.cpp (limited to 'datastructures/stlPQ.cpp') 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 +template +using priorityQueue = __gnu_pbds::priority_queue>; // greater für Min-Queue + +int main() { + priorityQueue 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 pq2; + pq.join(pq2); // O(1) +} -- cgit v1.2.3