http://classfoo.com/ccby/article/cIBahI

#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
// 用在此处是为了方便简洁, 在实际编程中慎用
using namespace std;
void main()
{
int iarray[] = { , , , , , , , , , , };
vector<int> foo1(iarray, iarray + sizeof(iarray) / sizeof(int));
int iarray1[] = { , };
vector<int> foo2(iarray1, iarray1 + sizeof(iarray1) / sizeof(int));
int iarray2[] = { , };
vector<int> foo3(iarray2, iarray2 + sizeof(iarray2) / sizeof(int));
int iarray3[] = { , , , , , , , , , , };
vector<int> foo4(iarray3, iarray3 + sizeof(iarray3) / sizeof(int)); //找出foo1之中相邻元素值相等的第一个元素
cout << *adjacent_find(foo1.begin(), foo1.end()) << endl; //6 //找出foo1之中元素值为6的元素个数
cout << count(foo1.begin(), foo1.end(), ) << endl; //3 //找出foo1之中小于7的元素个数
cout << count_if(foo1.begin(), foo1.end(), bind2nd(less<int>(), )) << endl;//9 //找出foo1之中元素值为4的第一个元素所在位置的元素
cout << *find(foo1.begin(), foo1.end(), ) << endl;//4 //找出foo1之中大于2的第一个元素所在位置的元素
cout << *find_if(foo1.begin(), foo1.end(), bind2nd(greater<int>(), ))//3
<< endl; //找出foo1之中子序列foo2所出现的最后一个位置,再往后3个位置的元素
cout << *(find_end(foo1.begin(), foo1.end(), foo2.begin(),//8
foo2.end()) + ) << endl; //找出foo1之中子序列foo2所出现的第一个位置,再往后3个位置的元素
cout << *(find_first_of(foo1.begin(), foo1.end(), foo2.begin(),//7
foo2.end()) + ) << endl; //子序列foo3在foo1中出现的起点位置元素
cout << *search(foo1.begin(), foo1.end(), foo3.begin(), foo3.end())//5
<< endl; //查找连续出现3个6的起点位置元素
cout << *search_n(foo1.begin(), foo1.end(), , , equal_to<int>()) << endl;//6 //判断两个区间foo1和foo4相等否(0为假,1为真)
cout << equal(foo1.begin(), foo1.end(), foo4.begin()) << endl;//0 //查找区间foo4在foo1中不匹配点的位置
pair<std::vector<int>::iterator, std::vector<int>::iterator>result =
mismatch(foo1.begin(), foo1.end(), foo4.begin());
cout << result.first - foo1.begin() << endl;//6
}

vector 搜索的更多相关文章

  1. Longest common prefix | leetcode

    Write a function to find the longest common prefix string amongst an array of strings. 思路:要去是寻找字符串ve ...

  2. NAACL 2019 字词表示学习分析

    NAACL 2019 表示学习分析 为要找出字.词.文档等实体表示学习相关的文章. word embedding 搜索关键词 word embedding Vector of Locally-Aggr ...

  3. Lucene in action 笔记 term vector——针对特定field建立的词频向量空间,不存!不会!影响搜索,其作用是告诉我们搜索结果是“如何”匹配的,用以提供高亮、计算相似度,在VSM模型中评分计算

    摘自:http://makble.com/what-is-term-vector-in-lucene given a document, find all its terms and the posi ...

  4. 在WinDbg中显示和搜索std::vector内容

    WinDbg从来都不擅长可视化.尽管Visual Studio一直都有autoexp.dat,而且最近还出现了本机调试器可视化工具,但WinDbg用户不得不满足于转储内存区域和搜索内存来识别模式.另一 ...

  5. ES搜索排序,文档相关度评分介绍——Vector Space Model

    Vector Space Model The vector space model provides a way of comparing a multiterm query against a do ...

  6. geotrellis使用(二十六)实现海量空间数据的搜索处理查看

    目录 前言 前台实现 后台实现 总结 一.前言        看到这个题目有人肯定会说这有什么可写的,最简单的我只要用文件系统一个个查找.打开就可以实现,再高级一点我可以提取出所有数据的元数据,做个元 ...

  7. [LeetCode] Search a 2D Matrix II 搜索一个二维矩阵之二

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  8. [LeetCode] Search in Rotated Sorted Array II 在旋转有序数组中搜索之二

    Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this ...

  9. [LeetCode] Search a 2D Matrix 搜索一个二维矩阵

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

随机推荐

  1. python2.7练习小例子(十九)

        19):题目:一球从100米高度自由落下,每次落地后反跳回原高度的一半:再落下,求它在第10次落地时,共经过多少米?第10次反弹多高? #!/usr/bin/python # -*- codi ...

  2. VS中的一些标记

    1.//ToDO:此标记运行时会显示在任务列表窗口中.

  3. c++ list_iterator demo

    #include <iostream> #include <list> using namespace std; typedef list<int> Integer ...

  4. jenkins手动安装插件

    插件下载地址: 搜索:https://plugins.jenkins.io/ 列表:https://updates.jenkins-ci.org/download/plugins/ 打开jenkins ...

  5. npx 命令介绍

    这个是在 npmv5.2.0引入的一条命令(查看),引入这个命令的目的是为了提升开发者使用包内提供的命令行工具的体验. 为什么引入这个命令 举个例子,我们开发中要运行 parcel 命令来打包:par ...

  6. selenium 的安装使用

    直接pip安装 pip install selenium 默认是火狐浏览器,需要安装下面网址的软件,解压后加入到环境变量中就可以了 https://github.com/mozilla/geckodr ...

  7. P3950部落冲突

    题面 \(Solution:\) 法一:LCT裸题 又好想又好码,只不过常数太大. 法二:树链剖分 每次断边将该边权的值++,连边--,然后边权化点权(给儿子),询问就查询从x到y的路径上的边权和,树 ...

  8. 今日头条 2018 AI Camp 视频面试

    1. 本次面试是在牛客网平台进行的,没有涉及到技术细节,面试官也说仅仅是聊天.但是,不知道是网络卡顿还是平台缘故,连接非常不稳定,经常听不到声音,对方那边噪音也特别大,面试体验不是很好. 2. 面试时 ...

  9. Structure From Motion(SFM,从运动恢复结构)

    Structure From Motion(SFM,从运动恢复结构) 阅读相关文献: Wu et al. Multicore Bundle Adjustment Agarwal et. al. Bun ...

  10. URAL 1732 Ministry of Truth(KMP)

    Description In whiteblack on blackwhite is written the utterance that has been censored by the Minis ...