-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathQueue
More file actions
39 lines (31 loc) · 839 Bytes
/
Queue
File metadata and controls
39 lines (31 loc) · 839 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
36
37
38
39
/* *********************************************************
* KNOWLEDGE CENTER
* st::queue
* Detailed Video Explanation: https://youtu.be/M73wcfBwX7Y
********************************************************** */
#include <iostream>
#include <queue>
using namespace std;
int main(){
queue<int> Q;
cout << std::boolalpha << Q.empty() << endl;
for(int i = 1; i <= 5; ++i)
Q.push(i);
// 1, 2, 3, 4, 5
cout << "front = " << Q.front() << ", back = " << Q.back() << endl;
cout << "size = " << Q.size() << endl;
Q.pop();
Q.pop();
// 3, 4, 5
cout << "front = " << Q.front() << ", back = " << Q.back() << endl;
cout << "size = " << Q.size() << endl;
cout << std::boolalpha << Q.empty() << endl;
return 0;
}
/*
size()
=
front(), back()
empty()
push(), pop()
*/