The use of queue (queue) in c++ stl

Enqueue, eg: q.push(x); Put x at the end of the queue.
Dequeue, for example: q.pop(); Pop the first element of the queue, note that the value of the popped element will not be returned.
Access the first element of the queue, such as: q.front(), which is the earliest element that was pushed into the queue.
Access the rear element, such as: q.back(), which is the last element pushed into the queue.
Judging that the queue is empty, for example: q.empty(), when the queue is empty, return true.

#include <cstdlib>
#include <iostream>
#include <queue>
#define q1 q
using namespace std;

intmain ()
{
int e,n,m;
queue<int> q;
if(q.empty()) cout<<"队列为空"<<endl;
for(int i=1;i<=10;i++) 
q.push(i);
if (!q.empty()) cout<< " Queue is not empty " << endl;

}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325109444&siteId=291194637