C++ Algorithm Function find_end ()C++ Algorithm find_end()function searches for the last occurrence of a pattern in the container, or say the last occurrence of a small portion of the sequence in the container. It basically searches the range specified by [first1,last1)for the occurrence of sequence which is defined by [first2,last2). If the occurrence is found, an iterator to the first element is returned, otherwise the last1 is returned. SyntaxParameterfirst1: It is a forward iterator to the first element in the range [first1, last1) where the element itself is included in the range. last1: It is a forward iterator to the last element in the range [first1, last1) where the element itself is not included in the range. first2: It is a forward iterator to the first element in the range [first2, last2) where the element itself is included in the range. last2: It is a forward iterator to the last element in the range [first2, last2) where the element itself is not included 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 last occurrence of [first2,last2)in the range [first1,last1).In case the sequence is not found then the function returns last1 value. Example 1Output: patt1 is last found at the position 5 patt2 is last found at the position 3 Example 2Output: 11 ComplexityThe complexity of the function is specified by count2*(1+count1-count2. Here countX specifies the distance between the firstX and lastX. Data racesObjects in both ranges are accessed. ExceptionsThe function throws an exception if any of the argument throws one. Next TopicC++ Algorithm find_first_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