Преглед на файлове

Replace the comparator of the priority queue

DricomDragon преди 5 години
родител
ревизия
fad165e7f6
променени са 1 файла, в които са добавени 4 реда и са изтрити 3 реда
  1. 4 3
      containers/main.cpp

+ 4 - 3
containers/main.cpp

@@ -1,6 +1,7 @@
 #include <iostream>
-#include <queue>
-#include <utility>
+#include <queue> // priority_queue
+#include <utility> // pair
+#include <functional> // greater
 
 using namespace std;
 
@@ -26,7 +27,7 @@ int main() {
 
 	cout << "## With pairs" << endl;
 
-	priority_queue<pair<int, int>> pqPair;
+	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pqPair;
 
 	pqPair.push(make_pair(4, 4));
 	pqPair.push(make_pair(4, 5));