template , for_each , fill
来源:互联网 发布:网络招商 编辑:程序博客网 时间:2024/05/01 14:29
#include <iostream> #include <vector> #include <algorithm> using namespace std; template <class T> class Print { public: void operator () (T& t) { cout << t << " "; } }; int main () { vector<int> v(10); Print<int> print; fill(v.begin(),v.end(),5); cout << "Vector v : "; for_each(v.begin(),v.end(),print); cout << endl; cout << "Size of v = " << v.size() << endl; cout << "v.clear" << endl; v.clear(); cout << "Vector v : "; for_each(v.begin(),v.end(),print); cout << endl; cout << "Size of v = " << v.size() << endl; cout << "Vector v is "; v.empty() ? cout << "" : cout << "not "; cout << "empty" << endl; return 0; } // Vector v : 5 5 5 5 5 5 5 // Size of v = 10 // v.clear // Vector v : // Size of v = 0 // Vector v is empty
code:
- template , for_each , fill
- STL-fill()填充算法以及for_each()算法
- C++学习 fill和fill_n和for_each()函数的应用
- for_each
- for_each
- for_each
- for_each
- for_each
- for_each
- for_each
- for_each
- for_each
- for_each
- STL fill()填充算法以及for_each()算法 取容器中的最大最小值min_element,max_element
- STL算法find,find_if,find_if_not,sort,fill,for_each,count,adjacent_find,random_shuffle,prev_permutation
- fill ()
- fill
- Fill
- android中创建有自身特色的字符串
- Qt 程序启动画面QSplashScreen的使用
- OSGi代码权限与Java Security机制
- HashMap java.util.ConcurrentModificationException
- 火狐和IE的window.event对象详解
- template , for_each , fill
- 进入mac时代,xcode来了
- http://blog.csdn.net/wei_wei_hnu/article/details/6634112
- android学习笔记之二
- 使用 Python 进行线程编程
- 为什么你总成为不了架构师?看了下 觉得确实不错
- 详解joomla制作中 jdoc
- DOM的简单介绍
- 用两个栈实现一个队列