MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Function main

CPP/stl/Deque_Operations.cpp:15–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13}
14
15int main()
16{
17 deque<int> dq;
18 dq.push_back(4);
19 dq.push_back(2);
20 dq.push_back(1);
21 dq.push_back(5);
22 dq.push_back(3);
23
24 cout<<"Deque contains:"<<dq.size()<<" elements"<<endl;
25
26 if (dq.empty())
27 {
28 cout<<"Empty"<<endl;
29 }
30 else
31 {
32 cout<<"Empty"<<endl;
33 }
34
35 //calling the function to print before sorting
36 print(dq);
37 //sorting the deque
38 sort(dq.begin(),dq.end());
39 //calling the function to print after sorting
40 print(dq);
41
42 //finding position of element with value 3
43 auto it1=find(dq.begin(),dq.end(),3);
44 //Inserting element on a particular position of deque
45 //element gets inserted on previous position of it1
46 dq.insert(it1,0);
47 print(dq);
48
49 //removing the 1st element of deque
50 dq.erase(dq.begin());
51 print(dq);
52
53 dq.clear();
54 cout<<"Deque contains:"<<dq.size()<<" elements"<<endl;
55 if(dq.empty())
56 {
57 cout<<"Empty"<<endl;
58 }
59 else
60 {
61 cout<<"Not Empty"<<endl;
62 }
63
64 return 0;
65}

Callers

nothing calls this directly

Calls 6

push_backMethod · 0.80
printFunction · 0.70
findFunction · 0.50
sizeMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected