#include<iostream>
using namespace std;
#include"vector"
#include"algorithm"
#include"functional" bool lowThree(int &iNum)
{
return (iNum > 3);
}
int main()
{
vector<int> v1;
v1.push_back(1);
v1.push_back(2);
v1.push_back(2);
v1.push_back(6);
v1.push_back(8); // adjacent_find在iterator对标识元素范围内,查找一对相邻重复元素,
//找到则返回指向这对元素的第一个元素的迭代器。否则返回past-the-end。
vector<int> ::iterator it = adjacent_find(v1.begin(), v1.end());
cout << *it << endl;
//初步结论,在stl算法中的谓词不能用数字代替,而函数可以用数字代替 //在有序序列中查找value,找到则返回true。注意:在无序序列中,不可使用。
bool b1 = binary_search(v1.begin(), v1.end(), 6);
cout << b1 << endl; //利用等于操作符,把标志范围内的元素与输入值比较,返回相等的个数。
int i1 = count(v1.begin(), v1.end(), 5);
cout << i1 << endl;
//参数中要求是谓词。可以直接写一个回调函数
int i2 = count_if(v1.begin(), v1.end(), lowThree);
cout << i2 << endl; vector<int> ::iterator it22 = find(v1.begin(), v1.end(), 5);
cout << *it22 << endl; vector<int> ::iterator it3 = find_if(v1.begin(), v1.end(), lowThree);
cout << *it3 << endl; system("pause");
}

  

最新文章

  1. poj 3734 Blocks
  2. ios 写项目的时候遇到的问题及解决方案(3)
  3. 利用SQL 建立和删除 LINKED SERVER
  4. Oracle双实例切换
  5. Composite模式
  6. [Ubuntu] ubuntu13.04 从php5.4降级到php5.3
  7. spark中streamingContext的使用详解
  8. ABBYY FineReader 12PDF选项卡有保存模式吗
  9. 利用反射自动生成SQL语句(仿Linq)
  10. 【Tools】Apache Maven 入门篇 ( 上 )
  11. 通过源码安装最新版Git
  12. iOS 苹果app提交 ITC.apps.validation.prerelease_build_missing
  13. delphi 实现微信开发
  14. [LeetCode]题解(python):141-Linked List Cycle
  15. ORA-12545: Connect failed because target host or object does not exist
  16. FlexPaper+SWFTool+操作类=在线预览PDF(转)
  17. HDU 5778 abs
  18. [译]前端JS面试题汇总 Part 1(事件委托/this关键字/原型链/AMD与CommonJS/自执行函数)
  19. 安装VisualStudio时失败,错误信息安装包失败或证书不在有效期内
  20. linux 设备驱动概述

热门文章

  1. Match function in R
  2. UVA11417 GCD
  3. P2221 [HAOI2012]高速公路
  4. Vue.set全局操作
  5. 【Hadoop 分布式部署 八:分布式协作框架Zookeeper架构功能讲解 及本地模式安装部署和命令使用 】
  6. facebook api之Access and Authentication
  7. communication
  8. 复习ing
  9. BZOJ 4584 【APIO2016】 赛艇
  10. Javascript中点击(click)事件的3种写法