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 algorithm is used to find elements that are equal to a value. It searches for elements equal to the value on the iterator range [first, last). If the element referred to by the iterator ITER satisfies * iter = value, the iterator ITER is returned, if not found, return last.
Function prototype:
template<class InputIterator, class Type> InputIterator find( InputIterator _First, InputIterator _Last, const Type& _Val );
Sample Code:
/*************************************** * **************************** Copyright (c) jerry Jiang * file name: Find. CPP * Author: Jerry Jiang * Create Time: 2011-9-29 0:03:25 * mail: jbiaojerry@gmail.com * blog: http://blog.csdn.net/jerryjbiao * Description: simple program c ++ STL algorithm series II * non variable algorithm: find the container element "find ************************************ * ****************************/# include <algorithm> # include <List> # include <iostream> using namespace STD; int main () {list <int> ilist; For (size_t I = 0; I <10; ++ I) {ilist. push_back (I + 1);} ilist. push_back (10); List <int >:: iterator ilocation = find (ilist. begin (), ilist. end (), 10); If (ilocation! = Ilist. end () {cout <"find element 10" <Endl ;}cout <"the previous element is:" <* (-- ilocation) <Endl; return 0 ;}
**************************************** **************************************** **************************************** *******
C ++ classic bibliography index and resource download:Http://blog.csdn.net/jerryjbiao/article/details/7358796
**************************************** **************************************** **************************************** ********