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 ...
随机推荐
- Symbol Table
[Symbol Table] In order for GDB to be useful to us, it needs to be able to refer to variable and fun ...
- chrome浏览器插件window resizer调试webapp页面大小
chrome浏览器插件window resizer可以调整当前浏览器分辨率大小 可以自定义大小,以适合于andorid和iphone设备
- linux which 查看可执行文件的位置
我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索: which 查看可执行文件的位置. whereis 查看文件的位置. ...
- VS2010 用WebBrowser控件 无响应
问题:偶尔我遇到这个问题,不知怎么的,拖放这个web控件它就卡死,无法响应,其他应用程序没有影响,任务管理器显示无法响应. 解决:原来是有道翻译的问题,具体为什么不清楚,只要一打开有道翻译,用web控 ...
- ASP.NET MVC- HtmlHelper的用法
在ASP.NET MVC框架中没有了自己的控件,页面显示完全就回到了写html代码的年代.还好在asp.net mvc框架中也有自带的HtmlHelper和UrlHelper两个帮助类.另外在MvcC ...
- 【转】Android TouchEvent事件传递机制
Android TouchEvent事件传递机制 事件机制参考地址: http://www.cnblogs.com/sunzn/archive/2013/05/10/3064129.html ht ...
- SOA服务开发小计
http://item.jd.com/11181846.html#comment SOA面向服务架构——SOA的概念 http://www.cnblogs.com/leslies2/archive/2 ...
- contentWindow 和contentDocument区别 及iframe访问
a>contentWindow 兼容各个浏览器,可取得子窗口的 window 对象. b>contentDocument Firefox 支持,> ie8 的ie支持.可取得子窗口的 ...
- Oracle 数据库链接
SQL> CREATE DATABASE LINK mydblink 2 CONNECT TO test IDENTIFIED BY test123 3 USING ...
- NameThreadForDebugging -- Naming threads for debugging
http://forums.devart.com/viewtopic.php?t=16907 type tagTHREADNAME_INFO = record dwType : LongWord; / ...