-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeque.cpp
40 lines (32 loc) · 955 Bytes
/
deque.cpp
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
40
#include <iostream>
#include <deque>
using namespace std;
int main()
{
deque<int> d;
d.push_back(1); //insert value end 1
d.push_front(2); //insert value front 1
for (int i : d)
{
cout<<i<<" ";
}
//d.pop_front(); //delete value from starting
//d.pop_back(); //delete value from end
// cout << endl;
// for (int i : d)
// {
// cout<<i<<" ";
// }
cout << "Print First Index Element-> " << d.at(1) << endl; //.at() is a built-in function which returns a element present at location i in given array
cout << "front " << d.front() << endl;
cout << "back " << d.back() << endl;
cout << "Empty or not " << d.empty() << endl;
cout << "before erase " << d.size() << endl;
d.erase(d.begin(), d.begin() + 1);
cout << "after erase " << d.size() << endl;
for (int i : d)
{
cout << i << endl;
}
return 0;
}