C++ Algorithm Function adjacent_find()C++ Algorithm adjacent_find() function performs a search operation on the range [first, last] for the very first occurrence of two consecutive matching elements. If such elements are found then an iterator to the first element of the two is returned. Otherwise, the last element is returned. SyntaxParameterfirst: It is a forward iterator to the first element in the range. last: It is a forward iterator to the last element in the range. pred: It is a binary function that accepts two elements as arguments and performs the task designed by the function. Return valueThe function returns an iterator to the first element of the range[first,last) if two consecutive matching elements are found else the last element is returned. Example 1Output: In the given range the first pair of sequence that is repeated are: 50 In the given range the second pair of sequence that is repeated are: 60 Example 2Output: 17 ComplexityThe complexity of the function is linear up to a distance between the first and last element. Data racesSome or all of the elements of the range are accessed. ExceptionsThe function throws an exception if any of the argument throws one. Next TopicC++ Algorithm any_of 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