Insert elements in vector to deque : deque insert « Deque « C++






Insert elements in vector to deque

   
#include <iostream>
#include <deque>
#include <vector>

using namespace std;

int main()
{
   int data[5] = { 6, 8, 7, 6, 5 };
   vector<int> v(5, 6);            //5 element vector
   deque<int> d(data, data + 5);
   deque<int>::iterator p;

   cout << "\nDeque values" << endl;
   for (p = d.begin(); p != d.end(); ++p)
      cout << *p << '\t';      
   cout << endl;
   d.insert(d.begin(), v.begin(), v.end());
   for (p = d.begin(); p != d.end(); p++)
   cout << *p << '\t';   
}
  
    
    
  








Related examples in the same category

1.Insert the remaining elements from the vector between the first and last deque elements