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上.依照性能测试结 ...
随机推荐
- Software Testing Techniques Homework 1
I have met some errors in recent years, one of them which impress me most. It happend when I try to ...
- python的enumerate函数
python的enumerate函数用于循环索引和元素 例如 foo = 'abc' for i , ch in enumerate(foo): print ch, '(%d)' % i 输出结果: ...
- Ubuntu-18.04下安装mysql
安装mysql服务器 1. sudo apt-get install mysql-server 2. sudo apt-get install mysql-client 登录问题 安装成功后,我们会发 ...
- java "Too small initial heap" 错误
Tomcat内存配置 JAVA_OPTS="-server -Duser.timezone=GMT+08-Xms1024m -Xmx1024m -XX:PermSize=1024m -Xmn ...
- In-app Billing 概述
这个文档讲解了In-app Billing的基础构成和功能,为了能够把In-app Billing功能添加到你的程序中,你需要很好的理解这些内容. 注意: 保证你的应用遵从发布地国家的相关法律. 举例 ...
- oracle给用户分配特定用户下特定表的只读权限
以下是测试过程,测试环境oracle 11.2.0.3 linux平台: 模拟将HR用户下的employees表的只读权限非配给test_ycr创建用户:SQL> create user tes ...
- January 05 2017 Week 1st Thursday
The true nobility is in being superior to your previous self. 真正的高贵在于超越过去的自己. I will be satisfied if ...
- XtraBackup出现 Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
解决办法1.建立一个软连接 ln -s /dat/data/mysql/mysql.sock /var/run/mysqld/mysqld.sock 解决办法2:指定--host=127.0.0.1
- PostgreSQL 连接的问题
一.在postgresql的安装文件夹\8.3\data\pg_hba.conf里面(或者在开始菜单程序下面的postgresql的配置文档)找到“# IPv4 local connections:” ...
- BZOJ4008:[HNOI2015]亚瑟王(DP,概率期望)
Description 小 K 不慎被 LL 邪教洗脑了,洗脑程度深到他甚至想要从亚瑟王邪教中脱坑. 他决定,在脱坑之前,最后再来打一盘亚瑟王.既然是最后一战,就一定要打得漂亮.众所周知,亚瑟王是一个 ...