cplusplus系列>algorithm>std::for_each
http://www.cplusplus.com/reference/algorithm/for_each/
对一个序列应用函数。可以是函数指针,或者是functor。
// for_each example
#include <iostream> // std::cout
#include <algorithm> // std::for_each
#include <vector> // std::vector void myfunction (int i) { // function:
std::cout << ' ' << i;
} struct myclass { // function object type:
void operator() (int i) {std::cout << ' ' << i;}
} myobject; int main () {
std::vector<int> myvector;
myvector.push_back();
myvector.push_back();
myvector.push_back(); std::cout << "myvector contains:";
for_each (myvector.begin(), myvector.end(), myfunction);
std::cout << '\n'; // or:
std::cout << "myvector contains:";
for_each (myvector.begin(), myvector.end(), myobject);
std::cout << '\n'; return ;
}
cplusplus系列>algorithm>std::for_each的更多相关文章
- hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏
huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...
- c++ stl algorithm: std::fill, std::fill_n
std::fill 在[first, last)范围内填充值 #include <iostream> #include <vector> #include <algori ...
- c++ stl algorithm: std::find, std::find_if
std::find: 查找容器元素, find仅仅能查找容器元素为<基本数据类型> [cpp] view plaincopy #include <iostream> #incl ...
- C++ 头文件系列 (algorithm)
简介 algorithm头文件是C++的标准算法库,它主要应用在容器上. 因为所有的算法都是通过迭代器进行操作的,所以算法的运算实际上是和具体的数据结构相分离的 ,也就是说,具有低耦合性. 因此,任何 ...
- cplusplus系列>utility>pair
http://www.cplusplus.com/reference/utility/pair/ 用于存储一对异构对象 // Compile: g++ -std=c++11 pair.cpp #inc ...
- for_each(c++11)
http://www.cplusplus.com/reference/algorithm/for_each/ template<class InputIterator, class Functi ...
- algorithm之不变序列操作
概述:不变序列算法,参见http://www.cplusplus.com/reference/algorithm/ /* std::for_each template <class InputI ...
- STL for_each()
http://www.cplusplus.com/reference/algorithm/for_each/ std::move()用于c++11 http://www.cplusplus.com/r ...
- STL_advance distance prev next
template<class InputIterator> typename iterator_traits<InputIterator>::difference_type d ...
随机推荐
- esb异常20160322_1948
异常1. Failed to find entry point for component, the following resolvers tried but failed: [ 2016-03-2 ...
- CentOS安装配置VSFTP服务器
{:toc} 前言 本文用最简单的方式创建FTP服务,即创建一个大家都可以访问的目录,没有涉及到各种权限限制. 创建目录 在安装配置ftp之前,首先创建一个目录,用来做ftp根目录.我创建的是/hom ...
- SharePoint 2013的100个新功能之社交
一:社会能力 SharePoint 2013引入了一个新东西叫做社会能力,使公司组织中的用户社会化协作.我的网站难以置信地做了改进以集成社会能力.除了我的网站,新的社区网站(新闻提要),关注用户和关注 ...
- Oracle数据库编程:使用PL/SQL编写触发器
8.使用PL/SQL编写触发器: 触发器存放在数据缓冲区中. 触发器加序列能够实现自动增长. 在触发器中不能使用connit和rollback. DML触发器 ...
- heritrix启动问题修正
今天抽时间想看看其他蜘蛛的情况,于是下载了heritrix-1.14.2.搜索了一下相关的安装介绍.基本步骤如下: (1)解压下载的heritrix-1.14.2.zip的压缩包,如将其放在E:\da ...
- 如何让windows服务器IIS支持.apk/.ipa文件下载
打开IIS服务管理器,找到服务器,右键-属性,打开IIS服务属性: 单击MIME类型下的“MIME类型”按钮,打开MIME类型设置窗口: 单击“新建”,建立新的MIME类型: 扩展名是:.apk MI ...
- 服务器资源共享--IIS站点/虚拟目录中访问共享目录(UNC)
本文重点描述如何使用IIS访问共享资源来架设站点或执行 ASP.Net 等脚本. 通常情况下,拥有多台服务器的朋友在使用IIS建立站点的时候,会遇到如何把多台服务器的资源合并到一起的问题.如何让A服务 ...
- [转]ViewPager onPageChangeListener总结
android ViewPager滑动事件讲解 首先ViewPager在处理滑动事件的时候要用到OnPageChangeListener OnPageChangeListener这个接口需要实现三个方 ...
- 修改SVN账户密码的方法
Case1: 在Eclipse 使用SVN 的过程中大多数人往往习惯把访问SVN 的用户名密码自动保存起来以便下次自动使用,不要再次手工输入,但是有些时候需要变更密码或者用户名,这时候 ...
- ie10中元素超出父元素的宽度时不能自动隐藏
(从已经死了一次又一次终于挂掉的百度空间人工抢救出来的,发表日期2014-02-21) 今天遇到一个问题,ie10中元素超出父元素的宽度时不能自动隐藏,而其余浏览器却正常显示. 解决方法是,手动给其设 ...