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 ...
随机推荐
- rapsbian下配置ngrok
访问https://ngrok.com,下载Linux/ARM版本的(因为PI为ARM的芯片,如果下载Linux版本的是无法正常使用的) 解压 $ unzip /path/to/ngrok.zip 注 ...
- 操作Cookie的一个陷阱服务器端获取不了maxAge或其它属性
搞了几天终于弄明白了这个问题: 在读取Cookie,然后操作时,除了getName(),getValue()外,不要妄图得到其他信息,如下方法不会得到值的:cookie.getMaxAge();=== ...
- Kafka学习记录
1 Kafka的基本介绍 Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.具有快速.可扩展.分布式.可复制等特点.Kafka与传 ...
- 最基本的Unix系统操作命令
基本知识点: OSX 采用的Unix文件系统,所有文件都挂在跟目录 / 下面,所以不在要有Windows 下的盘符概念. 你在桌面上看到的硬盘都挂在 /Volumes 下. 比如接上个叫做 USBHD ...
- 无责任Windows Azure SDK .NET开发入门篇三[使用Azure AD 管理用户信息--3.4 Edit修改用户信息]
3.4 Edit修改用户信息 我们用FormCollection简化了表单提交,非常方便的进行用户信息修改. [HttpPost, Authorize] public async Task<Ac ...
- (剑指Offer)面试题26:复杂链表的复制
题目: 请实现函数ComplexListNode* Clone(ComplexListNode* pHead),复制一个复杂链表. 在复杂链表中,每个结点除了有一个pNext指针指向下一个结点之外,还 ...
- CloudSTack4.2 查看所有虚拟机API测试
http://192.168.153.34:8080/ client/api? command=listVirtualMachines &response=json &sessionk ...
- Android Studio @Bind的用法,自动生成findViewById无需再实例化控件
第一步:app 的build.gradle文件中添加 如下代码: compile 'com.jakewharton:butterknife:7.0.0' 点击Sync Now 同步下载第二步:安装插件 ...
- Putty 工具 保存配置的 小技巧
用Putty 已经很长时间了,但一直被一个问题困扰,有时候是懒得去弄,反正也不怎么碍事,今天小研究了下,把这个问题解决了,心里也舒服了. Putty是一个免费小巧的Win32平台下的telnet,rl ...
- 【转】如何分析解决Android ANR
来自: http://blog.csdn.net/tjy1985/article/details/6777346 http://blog.csdn.net/tjy1985/article/detail ...