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. java初级应用:环境安装及配置

    相关文件下载: jdk下载路径:http://www.oracle.com/technetwork/java/javase/downloads/index.html eclipse下载路径:https ...

  2. phpcms2008网站漏洞如何修复 远程代码写入缓存漏洞利用

    SINE安全公司在对phpcms2008网站代码进行安全检测与审计的时候发现该phpcms存在远程代码写入缓存文件的一个SQL注入漏洞,该phpcms漏洞危害较大,可以导致网站被黑,以及服务器遭受黑客 ...

  3. [POJ 1004] Financial Management C++解题

    参考:https://www.cnblogs.com/BTMaster/p/3525008.html #include <iostream> #include <cstdio> ...

  4. Plsql developer 怎么在打开时登陆配置oracel client?

    配置前 logon 这块是空白的,该怎么配置呢? 看下面 --> 安装完plsql 后 需要安装 oracle client, 这里不再赘述,请自行百度.下面将贴出如何使用 oracle cli ...

  5. Dubbo原理及配置

    技术交流群:233513714 Dubbo的背景 随着互联网的发展,网站应用的规模不断扩大,常规的垂直应用架构已无法应对,分布式服务架构以及流动计算架构势在必行,亟需一个治理系统确保架构有条不紊的演进 ...

  6. 深入浅出 Webpack

    深入浅出 Webpack 评价 Webpack 凭借强大的功能与良好的使用体验,已经成为目前最流行,社区最活跃的打包工具,是现代 Web 开发必须掌握的技能之一.作者结合自身的实战经验,介绍了 Web ...

  7. 云计算之路-阿里云上:基于Xen的IO模型进一步分析“黑色0.1秒”问题

    在发现云服务器读取OCS缓存的“黑色0.1秒”是发生在socket读取数据时,而且是发生在读取开始的字节,甚至在socket写数据时(比如写入缓存key)也会出现超过50ms的情况,我们的好奇心被激发 ...

  8. 【题解搬运】PAT_L1-009 N个数求和

    从我原来的博客上搬运.原先blog作废. (伪)水题+1,旨在继续摸清这个blog(囧 题目 就是求N个数字的和.麻烦的是,这些数字是以有理数"分子/分母"的形式给出的,你输出的和 ...

  9. Python 3基础教程19-模块导入语法

    本文开始介绍模块导入的一些基本语法,我们现在还在Python自带的IDLE编辑器里写Python代码,如果你要需要一个功能,例如build-in的模块,那么你就需要先导入这个模块,然后才能使用这个模块 ...

  10. Android基本组件

    ①Activity和View负责与用户交互 ②Service通常位于后台,拥有独立的生命周期,为其他组件提供后台服务和监控其他组件运行状态 ③BroadcastReceiver广播消息接收器,类似事件 ...