【C++】STL之队列queue

1.头文件

# include<queue>

2.成员函数

  • empty()
    • 当队列为空时,返回true
  • size()
    • 返回队列内元素个数
  • front()
    • 返回队首元素
  • back()
    • 返回队尾元素
  • push(x)
    • 将x压入队尾
  • pop()
    • 弹出队首元素

3.使用方法

  1 #include <iostream>
  2 #include <queue>
  3 using namespace std;
  4 
  5 
  6 int main()
  7 {
  8     queue<int> temp;
  9     temp.push(0);
 10     temp.push(1);
 11     temp.push(2);
 12     temp.pop();
 13     cout<<temp.empty()<<endl;
 14     cout<<temp.size()<<endl;
 15     cout<<temp.front()<<endl;
 16     cout<<temp.back()<<endl;
 17 
 18     return 0;
 19 }
posted @ 2018-03-23 16:09  wanglei5205  阅读(610)  评论(0编辑  收藏  举报
levels of contents