#include <iostream>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
bool equal(pair<int,int> data, int target)
{
if (data.second == target)
{
return true;
}
else
{
return false;
}
}
int main()
{
//find_if用法;
map<int,int> mymap;
map<int,int>::iterator iter_find;
mymap[1] = 10;
mymap[2] = 20;
mymap[3] = 30;
mymap[4] = 40;
iter_find = find_if(mymap.begin(), mymap.end(), bind2nd(ptr_fun(equal),50));
if (iter_find != mymap.end())
{
cout<<" find!!!! "<<endl;
}
else
{
cout<< "Not find!!!! "<<endl;
}
//find用法;
map<char,int> mymap2;
map<char,int>::iterator it;
mymap2['a'] = 50;
mymap2['b'] = 100;
mymap2['c'] = 150;
mymap2['d'] = 200;
it = mymap2.find('b');
cout<<it->second<<endl;
return 0;
}
map find find_if用法
最新推荐文章于 2024-02-14 20:09:31 发布