Perform an in-place merge for two vectors
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<char> vectorObject1;
int i;
for(i = 0; i <26; i+=2)
vectorObject1.push_back('A'+i);
for(i = 0; i <26; i+=2)
vectorObject1.push_back('B'+i);
cout << "Original contents of vectorObject1:\n";
for(i = 0; i <vectorObject1.size(); i++)
cout << vectorObject1[ i ];
cout << endl;
inplace_merge(vectorObject1.begin(), vectorObject1.begin()+13, vectorObject1.end());
cout << "Result of merge:\n";
for(i = 0; i <vectorObject1.size(); i++)
cout << vectorObject1[ i ];
return 0;
}
Related examples in the same category