C++ Deque pop_front
C++ Deque pop_front function removes the first element from the deque and the size of the container is reduced by one.
Syntax
Example
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
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:
Output
20 30 40 50
In this example, pop_front function removes the first element i.e 10 from the deque.
Example 2
Let's see a simple example
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:
Output
C++ java .net
In this example, pop_front function removes the first string i.e "C" from the deque.