back_insert_iterator和insert_iterator
#include <iostream>
#include <string>
#include <iterator>
#include <vector>
#include <algorithm> void output(const std::string & s){std::cout << s << " ";} int main()
{
using namespace std;
string s1[4]={"fine", "fish", "fashion", "fate"};
string s2[2]={"busy", "bats"};
string s3[2]={"silly", "singers"};
vector<string> words(4);
copy(s1,s1+4,words.begin());
for_each(words.begin(),words.end(),output);
cout << endl;
copy(s2,s2+2,back_insert_iterator<vector<string> >(words));
for_each(words.begin(),words.end(),output);
cout << endl; copy(s3,s3+2,insert_iterator<vector<string> >(words,words.begin()));
for_each(words.begin(),words.end(),output);
cout << endl;
return 0;
}

back_insert_iterator和insert_iterator的更多相关文章
- ###STL学习--标准模板库
下面进行STL的学习.希望能了解标准模板库中的常用容器,迭代器,可以自由运用STL以提高编写代码的效率.下面的内容我想以知识点为总结,不再像<Effective C++>那样以章节进行总结 ...
- 适配器模式—STL中的适配器模式分析
适配器模式通常用于将一个类的接口转换为客户需要的另外一个接口,通过使用Adapter模式能够使得原本接口不兼容而不能一起工作的类可以一起工作. 这里将通过分析c++的标准模板库(STL)中的适配器来学 ...
- C++ 头文件系列(iterator)
简介 该头文件围绕迭代器展开,定义了一系列与迭代器有关的概念,但最最最重要的一点就是----它和其它容器一起实现了C++容器的Iterator设计模式. Iterators are a general ...
- STL中,back_insert_iterator与back_inserter的区别。
1.参考http://www.cplusplus.com网站关于back_insert_iterator与back_inserter的介绍之后,我总算明白了:back_insert_iterator, ...
- back_insert_iterator和iterator用起来不一样。
先看代码: #include<iostream> #include<vector> #include<algorithm> #include<iterator ...
- 迭代器适配器{(插入迭代器back_insert_iterator)、IO流迭代器(istream_iterator、ostream_iterator)}
一.迭代器适配器 反向迭代器 插入迭代器 IO流迭代器 其中反向迭代器可以参考以前的文章. 二.插入迭代器 插入迭代器实际上是一个输出迭代器(*it=; ++) back_insert_iterato ...
- iterator 及 迭代器模式(转发)
Iterator definitions An iterator is any object that, pointing to some element in a range of elements ...
- c++模板库(简介)
目 录 STL 简介 ......................................................................................... ...
- C++Primer 第十章
//1.标准库算法不仅可以应用于容器,还可以应用于内置数组,指针. //2.大多数算法都定义在头文件algorithm中.标准库还在头文件numeric中定义了一组数值泛型算法. //3.算法本身不会 ...
随机推荐
- kmp&字典树 模板
kmp: const int maxn=1e5+5; char s[maxn],p[maxn]; int nex[maxn]; int KmpSearch(char* s, char* p) { in ...
- 2018年11月16日SQL Server实验内容(触发器实验)
--注意:先把studentmanager数据库中的所有表用select into命令复制一份, --然后用复制后新表完成下面的实验,同时,对每个触发器都要进行验证. select *into dep ...
- 实验一 Python程序设计入门
学号20184307 2019-2020-2 <Python程序设计>实验1报告 课程:<Python程序设计> 班级: 1843 姓名: 章森洋 学号:20184307 实验 ...
- 17. vue-route详细介绍
前后端路由的来历 前端如何实现页面跳转但是不刷新? 了解hash和history两种方法 vue-router基本使用 安装vue-router 搭建vue-router框架的步骤 vue-route ...
- PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642
PAT (Advanced Level) Practice 1042 Shuffling Machine (20 分) 凌宸1642 题目描述: Shuffling is a procedure us ...
- LiteOS内核源码分析:任务LOS_Schedule
摘要:调度,Schedule也称为Dispatch,是操作系统的一个重要模块,它负责选择系统要处理的下一个任务.调度模块需要协调处于就绪状态的任务对资源的竞争,按优先级策略从就绪队列中获取高优先级的任 ...
- Shell 正则表达式详解
Shell 正则表达式 什么是正则表达式? 正则表达式在每种语言中都会有,功能就是匹配符合你预期要求的字符串. 为什么要学正则表达式? 在企业工作中,我们每天做的linux运维工作中,时刻都会面对大量 ...
- css 怎么在文字两边加上横线
<div class="title"> <h2 class="title-text"><span>工作经历</span ...
- 【oracle学习笔记02】Oracle Architecture —— Process Structure
Oracle中有三类进程: 1 User Process 2 Server Process Server Process is a program that directly interacts wi ...
- 201871030114-蒋鑫 实验三 结对项目—《D{0-1}KP 实例数据集算法实验平台》项目报告
项目 内容 课程班级博客链接☛ 班级博客 这个作业要求链接☛ 作业要求 我的课程学习目标☛ 1. 体验软件项目开发中的两人合作,练习结对编程(Pair programming).2. 掌握Github ...