从vector容器中查找一个子串:search()算法
来源:互联网 发布:js下载弹出路径选择框 编辑:程序博客网 时间:2024/06/06 16:44
如果要从vector容器中查找是否存在一个子串序列,就像从一个字符串中查找子串那样,次数find()与find_if()算法就不起作用了,需要采用search()算法:例子:
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int_tmain(int argc, _TCHAR* argv[])
{
vector<char> targetVec;
vector<char> sourchVec;
targetVec.push_back('\0');
targetVec.push_back('2');
sourchVec.push_back('3');
sourchVec.push_back('1');
sourchVec.push_back('\0');
sourchVec.push_back('\0');
sourchVec.push_back('2');
vector<char>::iterator posIt;
posIt= search(sourchVec.begin(),sourchVec.end(),targetVec.begin(),targetVec.end());
if(posIt != sourchVec.end())
{
cout<<"find it"<<endl;
}
return 0;
}
执行结果:find it
- 从vector容器中查找一个子串:search()算法
- Vector::find、search查找
- OC-在一个字符串中查找另一个字符串的范围;从一个字符串中提取子串
- 从母串中查找一个子串的函数strcspn/wcscspn
- 从右侧查找一个子串的strtstr()
- KMP 算法,search 子串
- STL中Vector容器Find的使用(int查找)
- 从list中查找子list
- 在一个字符串中查找最长回文子串
- 查找字符串中一个子串的个数
- java 在一个字符串中查找最大对称子串
- 2 在字符串中查找子串 算法
- Python:数据流中查找特定子串的简单算法
- kmp子串查找算法
- BF朴素查找算法(查找子串)
- 查找算法Search
- c++中vector容器
- 子字符串查找(上):从暴力算法到KMP
- 一个简单漂亮的404错误页面
- 5UCMS插件开发指南
- Oracle SQL性能优化
- sqlserver作业设置定时任务
- U956(MTK6589系列)移植乐蛙教程
- 从vector容器中查找一个子串:search()算法
- hdu 2870 DP
- 【VC编程技巧】文件☞2.3CArchive的用法
- VC6.0 编译 gdlib 库
- 迭代器适配器
- jquery.masonry插件怎么用
- 如何看懂源代码
- java语言基础(一)
- 通过实例学习Struts2 - 从struts-blank开始 (2)