// test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "stdafx.h"
#include <boost/heap/priority_queue.hpp>
#include <iostream>
using namespace std;
// PriorityQueue is expected to be a max-heap of integer values
template <typename PriorityQueue>
void basic_interface(void)
{
PriorityQueue pq;
pq.push(2);
pq.push(3);
pq.push(1);
cout << "Priority Queue: popped elements" << endl;
cout << pq.top() << " "; // 3
pq.pop();
cout << pq.top() << " "; // 2
pq.pop();
cout << pq.top() << " "; // 1
pq.pop();
cout << endl;
}
int main()
{
basic_interface< boost::heap::priority_queue<int> >();
return 0;
}
Boost的优先队列的简单示例
最新推荐文章于 2023-12-03 23:40:56 发布