- 先进先出,有两个口,没有迭代器,不能遍历,只有顶端的元素才能被访问。
queue构造函数
queue<T> queT;
queue(const queue &que) ;
queue存取、插入和删除操作
push(elem) ;
pop() ;
back();
front();
queue赋值操作
queue& operator=(const queue &que) ;
queue大小操作
empty();
size();
queue<int> q;
q.push(10) ;
q.push(20) ;
q.push(30) ;
q.push(40) ;
if (q.empty())
{
cout<<"容器为空"<<endl;
}
else
{
cout<<"容器非空"<<endl;
cout<<"size = "<<q.size()<<endl ;
cout<<"对头元素= "<<q.front()<<endl;
cout<<"队尾元素= "<<q.back()<<endl ;
}
cout<<"遍历队列"<<endl ;
while(!q.empty())
{
cout<<q. front()<<"";
q.pop() ;
}
priority_queue<int> big_heap;
priority_queue<int,vector<int>,less<int> > big_heap2;