template <class InputIterator1, class InputIterator2> bool includes( InputIterator1 xFirst1, InputIterator1 xLast1, InputIterator2 xFirst2, InputIterator2 xLast2 );
#include <algorithm>
template <class InputIterator1, class InputIterator2, class BinaryPred> bool includes( InputIterator1 xFirst1, InputIterator1 xLast1, InputIterator2 xFirst2, InputIterator2 xLast2, BinaryPred xComp );
#include <iostream> #include <vector> #include <algorithm> int main() { using namespace std; // Create two vector instances vector<int> qV1; qV1.push_back(-3); qV1.push_back(-1); qV1.push_back(0); qV1.push_back(1); vector<int> qV2; qV2.push_back(-3); qV2.push_back(0); qV2.push_back(1); vector<int>::iterator qIter; cout << "( "; for (qIter = qV1.begin(); qIter != qV1.end(); ++qIter) { cout << *qIter << " "; } cout << ") "; // Test first inclusion bool bInc = includes(qV1.begin(), qV1.end(), qV2.begin(), qV2.end()); cout << ((bInc) ? "includes" : "does not include"); cout << " ( "; for (qIter = qV2.begin(); qIter != qV2.end(); ++qIter) { cout << *qIter << " "; } cout << ")" << endl; cout << "( "; for (qIter = qV2.begin(); qIter != qV2.end(); ++qIter) { cout << *qIter << " "; } cout << ") "; // Test opposite inclusion bInc = includes(qV2.begin(), qV2.end(), qV1.begin(), qV1.end()); cout << ((bInc) ? "includes" : "does not include"); cout << " ( "; for (qIter = qV1.begin(); qIter != qV1.end(); ++qIter) { cout << *qIter << " "; } cout << ")" << endl; // Keep the window open cin.get(); return 0; }
© 20072024 XoaX.net LLC. All rights reserved.