Declaration
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);
Description
For the sequence in the range
[ first1, last1)
and
the sequence
in the range beginning at first2
, each
mismatch function returns a
pair of iterators i and
j referring to the first elements
and
, respectively, such that
and
are
different , or the pair of last1
and the location n locations past first2, where n is the size of the range [ first, last)
, if no such
difference occurs.
In the first function checks for element equality are made
with operator==, while in the second they are made with the function
object
binary_pred.
Type requirements
Group Non-mutating sequence operations.
Time complexity Linear.
If a mismatch is found, then the number of equality operations is the size of the range [ first1, i] ; otherwise, the number of equality operations is the size of the range [ first1, last1) .
Space complexity Constant.
Mutative? No.
Glossary terms BinaryPredicate, constant space, dereference type, function object, function object type, InputIterator, iterator, linear time, mutative, operator ==, pair, predicate, range, sequence.
Example Select here to view the source code for the example.
Implementation Select here to view source code (Copyright (C) 1994, Hewlett-Packard Company) for this algorithm.