-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdequeue.cpp
More file actions
executable file
·37 lines (30 loc) · 967 Bytes
/
Copy pathdequeue.cpp
File metadata and controls
executable file
·37 lines (30 loc) · 967 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
#include <bits/stdc++.h>
#include <deque>
using namespace std;
int main()
{
deque<int> a;
a.push_front(10); // adding element at the start
a.push_front(20);
a.push_front(30);
a.push_front(40);
a.push_front(50);
a.push_front(60);
// a.pop_front(); // removing element from the beginning
// a.pop_back(); // removing the last element
cout << "Max_Size -> " << a.max_size() << endl; // Showing the max size of the dequeue
cout << "Size -> " << a.size() << endl; // Showing the size/ Number of item of the dequeue
cout << "Before Erase: ";
for (int i : a)
{
cout << i << " ";
}
cout << endl;
a.erase(a.begin(), a.begin() + 4); // Erase item form e certain range to a certain range
// begin and end provides the memory address of first and last element
cout << "After Erase: ";
for (int i : a)
{
cout << i << " ";
}
}