C++ Algorithm Functions mismatch()C++ Algorithm mismatch() function compares both the containers to spot for any mismatch of values. The function returns the first element of both the containers that does not match. SyntaxParameterfirst1: It is an input iterator to the first element of the [first1, last1). last1: It is an input iterator to the last element of the [first1, last1). first2: It is an input iterator to the first element of the [first2, last2). pred: It is a binary function that accepts two elements as arguments and performs the task designed by the function. Return valueIf the function finds a pair of elements that does not match then it returns the first pair of such element, one from each container. In case none of the elements from the containers match the the function returns the pair(first1, first2) If the entire element in the pair matches then the function returns a pair of last1 and the element with same respective position to last1 in the second container. Example 1Output: Out of the given elements the first mismatching pair is: 30 and 80 The next pair of mismatching elements are: 40 and 320 Example 2Output: From the first container the element that does not match is: 23 From the second container the element that does not match container is: 1 From firt container return value is:12 From second container return value is: 1 ComplexityThe function has linear complexity from the first1 element to the last1 element. Data racesObjects in both ranges are accessed. ExceptionsThe function throws an exception if any of the argument throws one. Next TopicC++ Algorithm move backward Function |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India