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上.依照性能测试结 ...
随机推荐
- HDFS原理解析
一.HDFS简介 HDFS为了做到可靠性(reliability)创建了多分数据块(data blocks)的复制(replicas),并将它们放置在服务器群的计算节点中(computer nodes ...
- springmvc中Controller前端控制器的映射与返回数据,以及异常处理
.@RequestMapping映射 该注解中存的是映射路径的字符串 1.1 value的值是一个数组,也就是说可以定义多个访问路径,同时“.action”可以省略,前端控制器中主要查找主体部分.注意 ...
- OpenStack 学习笔记 (三)
个人网站:臭蛋www.choudan.net 一直苦于不知道如何加入到开源社区参与开发,感受开源社区分布式协作开发和巨神们coding的魅力,特意在网上查了资料,直接指导的很少,还得的靠官网上的文档. ...
- LeetCode 1. Two Sum (JavaScript)
1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a ...
- 原生mybaits学习笔记
目录 简介 maven引入 核心配置文件 方式一(简单) 配置 操作 方式二(old) 创建接口 配置mapper.xml 实现接口 操作 方式三(常用) 创建接口 配置mapper.xml 操作 配 ...
- [翻译] MagicPie
MagicPie Powerful pie layer for creating your own pie view. PieLayer provide great animation with si ...
- 海量数据处理面试题(2) 将用户的query按出现频度排序
问题描述: 有10个文件,每个文件1G,每个文件的每一行存放的都是用户的query,每个文件的query都可能重复.要求你按照query的频度排序. 分析:一般海量数据采用分治法时,都要用到哈希,将相 ...
- how to drop multiple talbes in oracle use a sigle query
Tool:PL/SQL developer Syntax:SELECT 'DROP TABLE ' || table_name || ';' FROM user_tables; 1.then you ...
- Exchange Server 2016 安卓手机打不开超过10M的附件问题处理
华为手机配置Exchange Server 2016 时,打不开超过10M的附件,如PPT或者是DOC之类的附件,而iphone手机确可以,因为iphone手机使用了IMAP协议,安卓手机如果使用I ...
- ASP.NET 控件不可编辑
前台页面的解析后的html代码为disabled="disabled",而在后台我们需要设置控件的Enabled=false:即可.