标签:stl return top names str function turn empty space
1 #include <iostream> 2 #include <vector> 3 #include <queue> 4 #include <functional> 5 #include <string> 6 using namespace std; 7 template <typename PriorityQueue> 8 void dumpContents(const string & msg,PriorityQueue & pq) 9 { 10 cout<<msg<<":"<<endl; 11 while(!pq.empty()) 12 { 13 cout<<pq.top()<<endl; 14 pq.pop(); 15 } 16 } 17 int main() 18 { 19 priority_queue<int> maxPQ; 20 priority_queue<int,vector<int>,greater<int> > minPQ; 21 22 minPQ.push(4); 23 minPQ.push(3); 24 minPQ.push(5); 25 maxPQ.push(4); 26 maxPQ.push(3); 27 maxPQ.push(5); 28 29 dumpContents("minPQ",minPQ); 30 dumpContents("maxPQ",maxPQ); 31 32 return 0; 33 }
标签:stl return top names str function turn empty space
原文地址:http://www.cnblogs.com/luozhijun/p/6880449.html