- push()
- empty()
- size()
- front()
- backQ)
- pop()
- emplace()
- swap()
FIFO--First in first out
Example:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
queue<int> q; //NOTE - 1 array declatation
q.push(5);
q.push(6);
q.push(7);
q.push(8);
queue<int> q2;
q2.push(11);
q2.push(12);
q2.push(13);
q2.push(14);
// queue<int>::iterator it; /// iterator declatation
// ///////// size ////////////
cout <<"size : "<< q.size() << endl;
///////// Front ////////////
cout << "front : " << q.front() << endl;
///////// Back ////////////
cout <<"Back : "<< q.back() << endl;
///////// empty ////////////
cout <<"empty : "<< q.empty() << endl;
///////// pop ////////////
q.pop() ;
cout << "front : " << q.front() << endl;
q.swap(q2);
// Print the queue
while (!q.empty())
{
cout << q.front() << " ";
q.pop();
}
}
0 Comments