vector 搜索
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 搜索的更多相关文章
- Longest common prefix | leetcode
Write a function to find the longest common prefix string amongst an array of strings. 思路:要去是寻找字符串ve ...
- NAACL 2019 字词表示学习分析
NAACL 2019 表示学习分析 为要找出字.词.文档等实体表示学习相关的文章. word embedding 搜索关键词 word embedding Vector of Locally-Aggr ...
- 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 ...
- 在WinDbg中显示和搜索std::vector内容
WinDbg从来都不擅长可视化.尽管Visual Studio一直都有autoexp.dat,而且最近还出现了本机调试器可视化工具,但WinDbg用户不得不满足于转储内存区域和搜索内存来识别模式.另一 ...
- ES搜索排序,文档相关度评分介绍——Vector Space Model
Vector Space Model The vector space model provides a way of comparing a multiterm query against a do ...
- geotrellis使用(二十六)实现海量空间数据的搜索处理查看
目录 前言 前台实现 后台实现 总结 一.前言 看到这个题目有人肯定会说这有什么可写的,最简单的我只要用文件系统一个个查找.打开就可以实现,再高级一点我可以提取出所有数据的元数据,做个元 ...
- [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 ...
- [LeetCode] Search in Rotated Sorted Array II 在旋转有序数组中搜索之二
Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this ...
- [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 ...
随机推荐
- 分分钟教你学习GIt
Git配置: $ git config --global user.name "awen" $ git config --global user.email "awen@ ...
- 如何在hadoop中使用外部的python程序文件
业务场景大概是这样,我需要在公司hadoop集群上对博文进行结巴分词.我的数据是存储在hive表格中的,数据量涉及到五百万用户三个月内发的所有博文. 首先对于数据来说,很简单,在hive表格中就是两列 ...
- Windows和Linux系统下,虚拟环境安装的全面说明和详细步骤
虚拟环境的创建和使用 用途: 1.在同一台电脑安装同一个包的不同版本 2.记录项目所用的所有的包的版本,方便部署. 如何使用: 1.创建虚拟环境 mkvirtualenv 虚拟环境名 -p pyt ...
- http一些常见知识记录
HTTP请求包(浏览器信息) 我们先来看看Request包的结构, Request包分为3部分,第一部分叫Request line(请求行), 第二部分叫Request header(请求头),第三部 ...
- UVA10474 Where is the Marble?【排序】
参考:https://blog.csdn.net/q547550831/article/details/51326321 #include <iostream> #include < ...
- Git使用之一:创建仓储和提交文件
一.前期工作: 1.准备自己的文件夹用于同步文件 2.准备自己的Git账号,并设置好项目(推荐使用国产的码云) 3.安装Git软件 (下载地址: 32-bit Git for Window ...
- Hibernate-ORM:14.Hibernate中的命名查询
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客讲述命名查询,所谓命名查询是什么呢? Hibernate中允许我们在xml,实体类,甚至注解的方式来编 ...
- java Vector向量
9.3.4 Vector向量 [专业IT培训机构,真正零首付入学www.bjsxt.com] Vector底层是用数组实现的List,相关的方法都加了同步检查,因此“线程安全,效率低”. 比如,ind ...
- 清除远程桌面连接记录和SQLSERVER 连接记录的办法
1.清除远程桌面连接记录: 清除远程桌面访问痕迹.使用windows系统自带的“远程桌面协助”mstsc进行远程,如果连接的用户多了,会留下访问的痕迹.虽然能带来方便,但是如果对于公用电脑来说,这些访 ...
- 【jQuery】 选择器
[jQuery] 选择器 资料: w3school http://www.w3school.com.cn/jquery/jquery_ref_selectors.asp 1. 标签选择器 : $(& ...