Deque Pop Front Function - C++ Programming Tutorial
C++ Course / STL Queue & Stack / Deque Pop Front Function

Deque Pop Front Function

BLUF: Mastering Deque Pop Front Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Deque Pop Front Function

C++ is renowned for its efficiency. Learn how Deque Pop Front Function enables low-level control and high-performance computing in the tutorial below.

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

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 instance, the pop_front method eliminates the initial element, which is 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 instance, the pop_front method eliminates the initial string, which is "C", from the deque.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience