搜索算法
常用的搜索算法可参看下表。
函数名 |
算法描述 |
search |
搜索迭代器区间中与另一个迭代器区间所有元素匹配的第一次的位置 |
search_n |
搜索迭代器区间中与若干个相同元素匹配的第一次的位置 |
binary_search |
以二分法在有序序列中查找指定值,找到返回true,否则返回false |
搜索算法的具体使用,可参看下面的示例代码。
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
static void PrintVector(vector<int>::const_iterator itBegin, vector<int>::const_iter