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上.依照性能测试结 ...
随机推荐
- iphone崩溃日志分析工具symbolicatecrash用法
Symbolicatecrash是Xcode自带的一个分析工具,可以通过机器上的崩溃日志和应用的.dSYM文件定位发生崩溃的位置,把crash日志中的地址替换成代码相应位置. 使用效果: 分析前: T ...
- Remove Duplicates from Sorted List 去除链表中重复值节点
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- centos虚拟机下安装nginx
通过yum安装 yum install epel-release -y(企业级的镜像源) yum install nginx-y 启动.停止.重启 service nginx start servic ...
- redis在windows上安装+RedisDesktopManager
redis我就不在这里介绍了,这里直接介绍windows安装redis服务,网上有很多介绍windows版,我这边安装的是一个极简版的. redis官方下载地址:https://redis.io/do ...
- 基于bootstrap的模态框的comfirm弹窗
完成的效果如下: html代码如下: <button id="btn">点击弹出弹框</button> <!-- 弹出框 --> <div ...
- Andriod(3)——Understanding Android Resources
Now, we will follow that introduction with an in-depth look at Android SDK fundamentals and cover re ...
- 乘风破浪:LeetCode真题_009_Palindrome Number
乘风破浪:LeetCode真题_009_Palindrome Number 一.前言 如何判断一个整型数字是回文呢,我们可能会转换成String来做,但是还有更简单的方法. 二.Palindrome ...
- Linux下打包压缩war、解压war包和jar命令
情景:把project_a文件夹下的文件打包成project.war 1. 打包 jar -cvf project.war /project_a 说明: -c 创建war包 -v 显示过程信息 -f ...
- Eclipse和JDK的安装配置
工欲善其事,必先利其器.最近开始学习Java语言,必不可少的要先安装一个IDE,我选择了eclipse,下面我们讲讲如何来安装及配置. Step1:工具的下载 这里我们需要用到三个工具安装包,JDK. ...
- CSS加载性能优化
将首屏页面要用到的CSS文件,放在页面头部加载,其他模块的CSS可以使用异步加载:loadCSS 和 Preload. 关于preload,推进2篇文章给大家看下: 1.通过rel="pre ...