English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C++ Usage and examples of Deque end()

C++ Deque (Double-Ended Queue)

C ++ The end() function of Deque returns an iterator pointing to the tail, which points to the next position after the last element of the container. If the deque container is empty, the value returned by the end() function is the same as that returned by the begin() function. It is located after the last element and does not point to any element.

Syntax

iterator end();

Parameters

It does not contain any parameters.

Return value

It returns an iterator pointing to the tail.

Example1

Let's see a simple example

#include #include using namespace std;
int main()
{
 dequek={10,20,30,40,50};
 deque::iterator itr = k.begin();
 while (itr != k.end())
 {
  cout <<*itr;
  cout << " \t";
  ++itr;
 } 
   return 0;
}

Output:

10 20 30 40 50

In this example, use the end() function in the while loop to iterate over the entire double-ended queue container.

C++ Deque (Double-Ended Queue)