functional filter()
#include "pch.h"
#include <iostream>
#include <deque>
#include <string>
#include <list>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std; template<typename InputIterator, typename OutputIterator,typename ElemType, typename Comp>
OutputIterator
filter(InputIterator first, InputIterator last,
OutputIterator at, const ElemType &val, Comp pred)
{
while((first=find_if(first, last, bind2nd(pred, val)))!=last)
{
cout << "found value:" << *first << endl;
*at++ = *first++;
}
return at;
} int main()
{
const int elem_size = ;
int ia[elem_size] = { ,,,,,,, };
vector<int> ivec(ia,ia+elem_size);
int ia2[elem_size];
vector<int> ivec2(elem_size);
cout << "filtering integer array for values less than 8\n";
filter(ia, ia + elem_size, ia2, elem_size, less<int>());
cout << "filtering integer vector for values greater than 8\n";
filter(ivec.begin(), ivec.end(), ivec2.begin(), elem_size, greater<int>());
return ;
}
functional filter()的更多相关文章
- django 操作数据库--orm(object relation mapping)---models
思想 django为使用一种新的方式,即:关系对象映射(Object Relational Mapping,简称ORM). PHP:activerecord Java:Hibernate C#:Ent ...
- Functional Programming without Lambda - Part 1 Functional Composition
Functions in Java Prior to the introduction of Lambda Expressions feature in version 8, Java had lon ...
- 转:LAV Filter 源代码分析
1: 总体结构 LAV Filter 是一款视频分离和解码软件,他的分离器封装了FFMPEG中的libavformat,解码器则封装了FFMPEG中的libavcodec.它支持十分广泛的视音频格式. ...
- ReactiveCocoa与Functional Reactive Programming
转自 http://blog.leezhong.com/ios/2013/06/19/frp-reactivecocoa.html Functional Reactive Programming(以下 ...
- java functional syntax overview
Defining a Functional Interface @FunctionalInterface public interface TailCall<T> { TailCall&l ...
- Starter Set of Functional Interfaces
Java Development Kit 8 has a number of functional interfaces. Here we review the starter set-the int ...
- Demo of Python "Map Reduce Filter"
Here I share with you a demo for python map, reduce and filter functional programming thatowned by m ...
- LAV Filter 源代码分析 4: LAV Video (2)
上一篇文章分析了LAV Filter 中的LAV Video的两个主要的类:CLAVVideo和CDecodeThread.文章:LAV Filter 源代码分析 3: LAV Video (1) 在 ...
- Java Bloom filter几种实现比较
英文原始出处: Bloom filter for Scala, the fastest for JVM 本文介绍的是用Scala实现的Bloom filter. 源代码在github上.依照性能测试结 ...
随机推荐
- 如何在Ubuntu上安装gcc-6.3
装显卡驱动推荐 gcc 6.3 版本,其实linux上多个版本的gcc是可以共存的,需要的的时候切换就好,参加之前的博客 https://www.cnblogs.com/jins-note/p/951 ...
- linux整个日志目录查询记录
在linux下面需要查看整个目录的日志,搜索用户的一个行为.因为不知道具体是那一天,一个个的查询也可以,但是太麻烦.可以用过下面的命令来实现: rep -iRl "关键字" ./ ...
- react入门参考资料
ReactJS简介 React 起源于 Facebook 的内部项目,因为该公司对市场上所有 JavaScript MVC 框架,都不满意,就决定自己写一套,用来架设 Instagram 的网站.做出 ...
- centos安装flash
自己操作步骤: 1 :http://get.adobe.com/cn/flashplayer/ 还是进入此下载页选择“.rpm,适用于其它Linux”,下载该rpm文件 2 :# rpm -iv ...
- @WebServlet
编写好Servlet之后,接下来要告诉Web容器有关于这个Servlet的一些信息.在Servlet 3.0中,可以使用标注(Annotation)来告知容器哪些Servlet会提供服务以及额外信息. ...
- 对于大型公司项目平台选择j2ee的几层认识
我是一个从野路子上一路走来的程序员,现在主要用.net做方案.选.net不选jave并没有什么特别的原因,只不过是因为我自己从c,java学起,后来被vs这个工具所吸引, 很熟悉这个平台罢了,从业15 ...
- Java Spring中@Query中使用JPQL LIKE 写法
两种方式 // 一 public List<TestEntity> searchByJpql(){ String jpql = "select k from TestEntity ...
- ubuntu搭建LAMP全教程及简单使用
一:安装: 参考:http://jingyan.baidu.com/article/a681b0de36ad683b18434691.html 本经验向你展示如何在ubuntu14.04 环境下搭建a ...
- C# WinForm窗体及其控件自适应各种屏幕分辨率
C# WinForm窗体及其控件自适应各种屏幕分辨率 一.说明 我们自己编写程序的界面,会遇到各种屏幕分辨率,只有自适应才能显的美观.实际上,做到这点也很简单,就是首先记录窗体和它上面控件的初始位置 ...
- 9、Node.js Stream(流)
#########################################################################介绍Node.js Stream(流)Stream 是 ...