您的位置:首页 > 产品设计 > UI/UE

STL_queue

2014-03-25 15:02 267 查看
queue and priority_queue

push/

pop/

top/

emtpy/

size

priority_queue: default to sort the queue as 6.5.4.3, greater stands front

if we wanna ascending order, using__

priority_queue<int, vector<int>, less<int> > pri_que;

#include <iostream>
#include <list>
#include <vector>
#include <queue>
using namespace std;

int main ()
{
int tmp[] = {1,2,3,4};
priority_queue<int> q1(tmp,tmp+4);
priority_queue<int,vector<int>,less<int> > pq; //default to greater
q1.push(1);
q1.push(6);
pq.pop();
cout<<q1.top()<<endl;

pq.size();
pq.empty();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: