流迭代器的一些作用
来源:互联网 发布:女朋友 程序员 编辑:程序博客网 时间:2024/06/03 21:15
流迭代器一般有下面的几种作用:
//利用流迭代器填充vector { <span style="white-space:pre"></span>ifstream in("test.txt"); <span style="white-space:pre"></span>istream_iterator<string> ibegin(in); <span style="white-space:pre"></span>istream_iterator<string> iend; <span style="white-space:pre"></span>vector<string> vec(ibegin, iend); <span style="white-space:pre"></span>copy(vec.begin(), vec.end(), ostream_iterator<string>(cout, "/n")); }
//利用输入流填充vector { <span style="white-space:pre"></span>vector<string> vec; <span style="white-space:pre"></span>copy(istream_iterator<string>(cin), istream_iterator<string>(), back_inserter(vec)); <span style="white-space:pre"></span>sort(vec.begin(), vec.end()); <span style="white-space:pre"></span>copy(vec.begin(), vec.end(), ostream_iterator<string>(cout,"/n")); }
//利用流迭代器保存vector内容到文件 { <span style="white-space:pre"></span>ifstream in("test.txt"); <span style="white-space:pre"></span>istream_iterator<string> ibegin(in); <span style="white-space:pre"></span>istream_iterator<string> iend; <span style="white-space:pre"></span>vector<string> vec(ibegin, iend); <span style="white-space:pre"></span>ofstream out("testcopy.txt"); <span style="white-space:pre"></span>copy(vec.begin(), vec.end(), ostream_iterator<string>(out, "/n")); }
0 0
- 流迭代器的一些作用
- 流迭代器的一些作用
- 一些软件的作用
- 一些jar的作用
- runtime 的一些作用
- 一些jar的作用
- this的一些作用
- 一些程序设计语言的作用、分类
- 一些头域的作用
- 一些jar包的作用
- 一些jar包的作用
- 一些jar包的作用
- 一些jar包的作用
- ovm一些宏的作用
- 一些jar包的作用
- 汇编语言一些寄存器的作用
- 一些简单函数的作用
- cocos2dx 的一些宏的作用
- 编译安装PHP5.6并解决PHP出现下载页面问题
- 金额转大写(java)
- no dll in java.library.path
- Hadoop学习笔记(一)
- uva 10891 - Game of Sum 动态规划 状态选取
- 流迭代器的一些作用
- 2015 移动技术白皮书
- - Kill the monster HDU2616
- c#常用描述统计方法总结
- mybatis jdbcType 对应javaType
- iOS提交AppStore后申请加急审核
- Dreamweaver8自动关闭问题
- iOS之UNIX(iOS追根溯源)
- Gird: 两种结构设计