English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C++ Deque (Double-ended Queue)
C ++ The emplace_front() function of the deque container adds a new element at the beginning of the container, and the size of the container increases by one.
void emplace_front(value_type val);
valInsert a new value at the beginning of the deque.
It does not return any value.
Let's look at a simple example
#include<iostream> #include<deque> using namespace std; int main() { dequefruit={"mango","banana"}; deque::iterator itr; fruit.emplace_front("apple"); fruit.emplace_front("strawberry"); for(itr=fruit.begin();itr!=fruit.end();++itr) std::cout << *itr << " "; return 0; }
Output:
strawberry apple mango banana
In this example, the emplace_front() function adds two strings, apple and strawberry, to the beginning of the deque.