C ++ STL's non-mutating algorithms is a set of template functions that do not destroy operation data, it is used for processing sequence data one by one, element search, subsequence search, statistics, and matching.
The find_end algorithm searches for the Child sequence that matches the last sequence with the other sequence. There are two function prototypes. In the iterator range [first1, last1), find the child sequence that matches the iterator range [first2, last2) element, returns the iterator or last1 of the first element.
Function prototype:
template<class ForwardIterator1, class ForwardIterator2> ForwardIterator1 find_end( ForwardIterator1 _First1, ForwardIterator1 _Last1, ForwardIterator2 _First2, ForwardIterator2 _Last2 );template<class ForwardIterator1, class ForwardIterator2, class Pr> ForwardIterator1 find_end( ForwardIterator1 _First1, ForwardIterator1 _Last1, ForwardIterator2 _First2, ForwardIterator2 _Last2, BinaryPredicate _Comp );
Example program:
/*************************************** * **************************** Copyright (c) jerry Jiang * file name: find_end.cpp * Author: Jerry Jiang * Create Time: 2011-10-12 20:07:20 * mail: jbiaojerry@gmail.com * blog: http://blog.csdn.net/jerryjbiao * description: A simple program interprets 12 * Non-Variable Algorithms in the C ++ STL algorithm series: find_end ********************************** * *******************************/# include <ALG Orithm >#include <vector >#include <iostream> using namespace STD; int main () {vector <int> V1; v1.push _ back (5 ); v1.push _ back (-2); v1.push _ back (4); v1.push _ back (3); v1.push _ back (-2); v1.push _ back (4 ); v1.push _ back (8); v1.push _ back (-2); v1.push _ back (4); v1.push _ back (9); vector <int >:: const_iterator ITER; cout <"V1:"; for (iter = v1.begin (); iter! = V1.end (); ++ ITER) {cout <* ITER <";}cout <Endl; vector <int> V2; v2.push _ back (-2 ); v2.push _ back (4); cout <"V2:"; for (iter = v2.begin (); iter! = V2.end (); ++ ITER) {cout <* ITER <"" ;}cout <Endl; vector <int >:: iterator iloaction; iloaction = find_end (v1.begin (), v1.end (), v2.begin (), v2.end (); If (iloaction! = V1.end () {cout <"V1 finds the last child sequence that matches V2. The starting position is:" <"V1 [" <iloaction-v1.begin () <"]" <Endl;} return 0 ;}
**************************************** **************************************** **************************************** *******
C ++ classic bibliography index and resource download:Http://blog.csdn.net/jerryjbiao/article/details/7358796
**************************************** **************************************** **************************************** ********