c++之STL(13) STL 算法 - 查找算法(4)find_first_of(b,e,sb,se) find_first_of(b,e,sb,se,bp)
来源:互联网 发布:张红兵 知乎 编辑:程序博客网 时间:2024/05/18 09:14
find_first_of(b,e,sb,se)
find_first_of(b,e,sb,se,bp)
使用逆向迭代器 没有find_last_of算法
STL 查找算法
find()
find_if()
search_n()
search()
find_end()
find_first_of()
adjacent_find()
string 查找函数和STL查找算法的比较
string函数 STL算法
find() find()
rfind() find() + 逆向迭代器
find() search()
rfind() find_end()
find_first_of() find_first_of()
find_last_of() find_first_of() + 逆向迭代器
find() 和rfind()是一对,search()和find_end()是一对
#include<iostream>#include<vector>#include<list>#include<string>#include<algorithm>using namespace std;int main(){vector<int> ivec;list<int> searchList;for (int i = 1; i <= 11; i++)ivec.push_back(i);for (vector<int>::iterator iter = ivec.begin(); iter != ivec.end(); iter++){cout << *iter;}cout << endl;searchList.push_back(3);searchList.push_back(6);searchList.push_back(9);// 找任意一个vector<int>::iterator pos;pos = find_first_of(ivec.begin(), ivec.end(), searchList.begin(), searchList.end());if (pos!=ivec.end()){cout << "找到了!位置:" << distance(ivec.begin(), pos) + 1 << endl;}elsecout << "没找到!";//从后面找vector<int>::reverse_iterator rpos;rpos = find_first_of(ivec.rbegin(), ivec.rend(), searchList.begin(), searchList.end());cout << "找到的位置:" << distance(ivec.begin(), rpos.base()) << endl;//string numerics("0123456789");string name("ra8d3k");// 找任何一个string::size_type p = name.find_first_of(numerics);if (p != string::npos)cout << "找到了,下标:" << p << endl;elsecout << "没找到!" << endl;//从后面开始找p = name.find_last_of(numerics);if (p != string::npos)cout << "找到了,下标:" << p << endl;elsecout << "没找到!" << endl;//system("pause");return 0;}
0 0
- c++之STL(13) STL 算法 - 查找算法(4)find_first_of(b,e,sb,se) find_first_of(b,e,sb,se,bp)
- c++之STL(13) STL 算法 - 查找算法(6)binary_search(b,e,v) binary_search(b,e,v,p) includes(b,e,sb,se) include
- c++之STL(13) STL 算法 - 查找算法(5)adjacent_find(b,e) adjacent_find(b,e,p)
- C++ STL 算法:查找算法(4)find_first_of
- c++之STL(13) STL 算法 - 查找算法(2)search_n() search_n(b, e, c, v) search_n(b, e, c, v, p)
- STL algorithm算法find_first_of(18)
- C++的STL之find_first_of
- 简单的程序诠释C++ STL算法系列之五:find_first_of
- find_first_of (STL Sample)
- STL(5)find_first_of函数
- STL 之find,find_if,find_end,find_first_of
- STL 之find,find_if,find_end,find_first_of
- STL_算法_查找算法(find_first_of、find_last_of)
- c++之STL(13) STL 算法 - 查找算法(1)
- C++ STL算法系列2---find ,find_first_of , find_if , adjacent_find的使用
- C++ STL算法系列2---find ,find_first_of , find_if , adjacent_find的使用
- C++ STL算法系列2---find ,find_first_of , find_if , adjacent_find的使用
- C++ STL算法系列2---find ,find_first_of , find_if , adjacent_find的使用
- 博弈论相关知识文档
- 七牛-获取空间域名(c#)
- Protractor
- 222.leetcode.Count Complete Tree Nodes(medium)[完全二叉树 节点个数]
- Linux简介
- c++之STL(13) STL 算法 - 查找算法(4)find_first_of(b,e,sb,se) find_first_of(b,e,sb,se,bp)
- Javascript 同步异步加载详解 (十足的好文章!!强烈推荐)
- leetcode--34. Search for a Range
- 微信配置模板消息进行订单消息推送[基于测试号]
- Codeforces Round #366 (Div. 2)
- 我的家教——面试
- 递归算法转换为非递归算法
- 10、java线性安全_并发容器_conCurrentHashMap
- zookeeper leader选举源码实现