STL中find函数
2015-09-05 16:21
483 查看
find声明:
[cpp]
view plaincopyprint?
[cpp]
view plaincopyprint?
void test_find()
{
std::list <int> L;
std::list <int>::iterator Iter;
std::list <int>::iterator result;
L.push_back(40);
L.push_back(20);
L.push_back(10);
L.push_back(30);
L.push_back(10);
std::copy(L.cbegin(), L.cend(), std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
result = std::find(L.begin(), L.end(), 10);
if (result == L.end())
std::cout << "There is no 10 in list L.";
else {
std::cout << "There is a 10 in list L";
if (++result != L.end())
std::cout << " and it is followed by a " << *result << ".";
}
std::cout << std::endl;
}
转自:/article/7701907.html
[cpp]
view plaincopyprint?
template<class InputIterator, class Type> InputIterator find( InputIterator _First, InputIterator _Last, const Type& _Val );示例:
[cpp]
view plaincopyprint?
void test_find()
{
std::list <int> L;
std::list <int>::iterator Iter;
std::list <int>::iterator result;
L.push_back(40);
L.push_back(20);
L.push_back(10);
L.push_back(30);
L.push_back(10);
std::copy(L.cbegin(), L.cend(), std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
result = std::find(L.begin(), L.end(), 10);
if (result == L.end())
std::cout << "There is no 10 in list L.";
else {
std::cout << "There is a 10 in list L";
if (++result != L.end())
std::cout << " and it is followed by a " << *result << ".";
}
std::cout << std::endl;
}
转自:/article/7701907.html
相关文章推荐
- 如何测试一支笔
- iOS App创建桌面快捷方式
- SQL Server 根据表名获取表的所有列及属性
- java 平衡二叉树的实现
- sharepoint 2016 学习系列篇(7)-如何给网站分配用户访问权限site permission for users
- Shell命令——使用命令
- Learning Markdown
- FluentData,它是一个轻量级框架,关注性能和易用性。
- YII的重写规则与URL的管理
- 解决方案:An error was encountered while running(Domain=FBSOpenApplicationErrorDomain, Code=4)
- 路由器端口映射教程
- grub救援以及演示
- sharepoint 2016 学习系列篇(6)-配置网站的备用网络映射
- 1234 签到题【几何】
- Hadoop 案例6-----TopN问题:求最大的K个值并排序
- 简单四则运算
- 1718:Rank
- 多线程实战(三)线程池
- 快速上手如何使用FluentData
- leetcode: (235) Lowest Common Ancestor of a Binary Search Tree