forked from dextel2/data-structures-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueue.cpp
More file actions
35 lines (30 loc) · 674 Bytes
/
Queue.cpp
File metadata and controls
35 lines (30 loc) · 674 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// basic implementation of STL queue functions;
#include <iostream>
#include <queue>
using namespace std;
void print(queue <int> q)
{
queue <int> ss = q;
while (!ss.empty())
{
cout <<" "<< ss.front();
ss.pop();
}
cout << '\n';
}
int main()
{
queue <int> Q;
Q.push(10);
Q.push(20);
Q.push(30);
cout << "The queue Q is : ";
print(Q);
cout << "\nQ.size() : " << Q.size();
cout << "\nQ.front() : " << Q.front();
cout << "\nQ.back() : " << Q.back();
cout << "\n queue after Q.pop() : ";
Q.pop();
print(Q);
return 0;
}