English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C++ Deque (Double-ended Queue)
C ++ Deque emplace_back()函数在双端队列的末尾添加了一个新元素,并且容器的大小增加了一个。
void emplace_back(value_type val);
val:在双端队列的末尾插入的新值。
它不返回任何值。
让我们看一个简单的实例
#include <iostream> #include<deque> using namespace std; int main() { dequed={1,2,3,4}; deque::iterator itr; d.emplace_back(5); for(itr=d.begin();itr!=d.end();++itr) std::cout << *itr <<" "; return 0; }
Output:
1 2 3 4 5
在此示例中,emplace_back()函数在双端队列的末尾添加了一个新元素,即5。
让我们看一个简单的实例
#include <iostream> #include<deque> using namespace std; int main() { dequech={'j','a','v'}; deque::iterator itr; ch.emplace_back('a'); for(itr=ch.begin();itr!=ch.end();++itr) std::cout << *itr; return 0; }
Output:
java
In this example, the emplace_back() function adds a new element, 'a', to the end of the deque.