Illustrating the generic search algorithm: Search for first occurrence of deque's contents as a subsequence of the vector contents : deque find « Deque « C++






Illustrating the generic search algorithm: Search for first occurrence of deque's contents as a subsequence of the vector contents

  
 

#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

int main()
{
  vector<int> vector1(20);
  deque<int>  deque1(5);

  int i;
  for (i = 0; i < 20; ++i) 
    vector1[i] = i;

  for (i = 0; i < 5; ++i) 
    deque1[i] = i + 5;


  vector<int>::iterator k = search(vector1.begin(), vector1.end(), deque1.begin(), deque1.end());

  for (i = 0; i < 5; ++i) 
    cout <<  *(k + i);

  return 0;
}

/* 
56789
 */        
    
  








Related examples in the same category

1.Use find the search an element in deque
2.Search across two deques