C++ Deque pop_front
The pop_front method in C++ Deque eliminates the initial element from the deque, consequently decreasing the container's size by one.
Syntax
void pop_front();
Parameter
It does not contain any parameter.
Return value
It does not return any value.
Example 1
Let's see a simple example
#include <iostream>
#include<deque>
using namespace std;
int main()
{
deque<int> d={10,20,30,40,50};
deque<int>::iterator itr;
d.pop_front();
for(itr=d.begin();itr!=d.end();++itr)
cout<<*itr<<" ";
return 0;
}
Output:
20 30 40 50
In this instance, the pop_front method eliminates the initial element, which is 10, from the deque.
Example 2
Let's see a simple example
#include <iostream>
#include<deque>
using namespace std;
int main()
{
deque<string> language={"C","C++","java",".net"};
deque<string>::iterator itr;
language.pop_front();
for(itr=language.begin();itr!=language.end();++itr)
cout<<*itr<<" ";
return 0;
}
Output:
C++ java .net
In this instance, the pop_front method eliminates the initial string, which is "C", from the deque.