Category: algorithms | Component type: function |
template <class InputIterator1, class InputIterator2> pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2); template <class InputIterator1, class InputIterator2, class BinaryPredicate> pair<InputIterator1, InputIterator2> mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryPredicate binary_pred);
The first version of mismatch finds the first iterator i in [first1, last1) such that *i != *(first2 + (i - first1)). The return value is a pair whose first element is i and whose second element is *(first2 + (i - first1)). If no such iterator i exists, the return value is a pair whose first element is last1 and whose second element is *(first2 + (last1 - first1)).
The second version of mismatch finds the first iterator i in [first1, last1) such that binary_pred(*i, *(first2 + (i - first1)) is false. The return value is a pair whose first element is i and whose second element is *(first2 + (i - first1)). If no such iterator i exists, the return value is a pair whose first element is last1 and whose second element is *(first2 + (last1 - first1)).
int A1[] = { 3, 1, 4, 1, 5, 9, 3 }; int A2[] = { 3, 1, 4, 2, 8, 5, 7 }; const int N = sizeof(A1) / sizeof(int); pair<int*, int*> result = mismatch(A1, A1 + N, A2); cout << "The first mismatch is in position " << result.first - A1 << endl; cout << "Values are: " << *(result.first) << ", " << *(result.second) << endl;
Contact Us | Site Map | Trademarks | Privacy | Using this site means you accept its Terms of Use |
Copyright © 2009 - 2016 Silicon Graphics International. All rights reserved. |