list<int> coll1 = { , , , , , , , ,  };

cout << "** collection 1: **" << endl;
ContainerUtil<list<int>>::printElements(coll1); vector<int> coll2;
copy(coll1.cbegin(), coll1.cend(), back_inserter(coll2)); cout << "** collection 2(copy back insert from collection 1): **" << endl;
ContainerUtil<vector<int>>::printElements(coll2); deque<int> coll3;
copy(coll1.cbegin(), coll1.cend(), front_inserter(coll3)); cout << "** collection 3(copy front insert from collection 1): **" << endl;
ContainerUtil<deque<int>>::printElements(coll3); set<int> coll4;
copy(coll1.cbegin(), coll1.cend(), inserter(coll4, coll4.begin())); cout << "** collection 4(copy general insert from collection 1): **" << endl;
ContainerUtil<set<int>>::printElements(coll4);

运行结果:

** collection 1: **
  1  2  3  4  5  6  7  8  9
** collection 2(copy back insert from collection 1): **
  1  2  3  4  5  6  7  8  9
** collection 3(copy front insert from collection 1): **
  9  8  7  6  5  4  3  2  1
** collection 4(copy general insert from collection 1): **
  1  2  3  4  5  6  7  8  9

STL - 迭代器 - 安插型迭代器的更多相关文章

  1. STL学习笔记(迭代器配接器)

    Reverse(逆向)迭代器 Reverse迭代器是一种配接器. 重新定义递增运算和递减运算.使其行为正好倒置. 如果你使用这类迭代器,算法将以逆向次序处理元素.所有标准容器都允许使用Reverse迭 ...

  2. STL源代码剖析(二) - 迭代器与traits技法

    提要 先看一段用迭代器的代码: int a[] = {1, 2, 3, 4, 5}; vector<int> v1( a, a+5); vector<int>::iterato ...

  3. c++ insert iterators 插入型迭代器

    insert iterators 插入型迭代器 (1)front inserters 前向插入迭代器 只适用于提供有push_front()成员函数的容器,在标准程序库中这样的容器是deque和lis ...

  4. STL六大组件之——迭代器这个东西

    迭代器:除了在其它语言中司空见惯的下标法访问容器元素之外,C++语言提供了一种全新的方法——迭代器(iterator)来访问容器的元素.迭代器其实类似于引用,指向容器中某一元素.换个方式来说,容器就是 ...

  5. STL源码剖析 迭代器(iterator)概念与编程技法(三)

    1 STL迭代器原理 1.1  迭代器(iterator)是一中检查容器内元素并遍历元素的数据类型,STL设计的精髓在于,把容器(Containers)和算法(Algorithms)分开,而迭代器(i ...

  6. stl之容器、迭代器、算法几者之间的关系

    转自:https://blog.csdn.net/bobodem/article/details/49386131 stl包括容器.迭代器和算法: 容器 用于管理一些相关的数据类型.每种容器都有它的优 ...

  7. SGI STL红黑树中迭代器的边界值分析

    前言 一段程序最容易出错的就是在判断或者是情况分类的边界地方,所以,应该对于许多判断或者是情况分类的边界要格外的注意.下面,就分析下STL中红黑树的迭代器的各种边界情况.(注意:分析中STL使用的版本 ...

  8. STL学习笔记(四) 迭代器

    条款26:iterator 优先于 const_iterator, reverse_iterator, const_reverse_iterator iterator, reverse_iterato ...

  9. STL之Iterator(迭代器)

    概述 根据迭代器功能的不同,将迭代器分为以下几类: Iterator Category Ability Providers Input iterator Reads forward istream O ...

随机推荐

  1. bzoj 1101

    其实这个用的是Mobius反演的第二种形式 F(d) = (n div d) * (m div d) f(d) = [ gcd(i,j)=d ] (i in [1,a], j in [1,b]) /* ...

  2. bzoj 2251

    第一道后缀数组 后缀数组要维护三个数组:sa(suffix array), rk(rank)和ht(height). 含义分别是: sa[i]:将后缀按照字典序排序后,第i大的后缀的起始位置. rk[ ...

  3. BZOJ 4443: [Scoi2015]小凸玩矩阵 最大流

    4443: [Scoi2015]小凸玩矩阵 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=4443 Description 小凸和小方是好 ...

  4. URAL 1997 Those are not the droids you're looking for 二分图最大匹配

    Those are not the droids you're looking for 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1 ...

  5. OpenERP实施记录(10):采购补货

    本文是<OpenERP实施记录>系列文章的一部分. 上文中业务部门接到沃尔玛三台联想Y400N笔记本电脑的订单,但是仓库无货.本文需要完成采购补货处理. 1. 联想YN400N是ABC公司 ...

  6. unity 3D + Google Play In-app Billing (IAB)(转) 热度 3

    最近由于工作需要,研究unity如何接入Google Play以实现游戏内购买.目前IAB的实现,prime31做的插件比较好,各平台的IAB均有,但费用相对过高(几乎都是70刀左右,可怜穷小子).在 ...

  7. 【spring boot】启动类启动 错误: 找不到或无法加载主类 com.codingapi.tm.TxManagerApplication 的解决方案

    导入的一个外部的spring boot项目,运行启动类,出现错误:找不到或无法加载主类 com.codingapi.tm.TxManagerApplication 解决方案: 将所有错误处理完成后,再 ...

  8. javascript函数中的匿名函数

    一般写函数,我们会这样调用: function add(x, y) { return x + y; } alert(add(2, 3)); 或者这样: var add = function(x, y) ...

  9. .Net线程问题解答

    基础篇 怎样创建一个线程 受托管的线程与 Windows线程 前台线程与后台线程 名为BeginXXX和EndXXX的方法是做什么用的 异步和多线程有什么关联 WinForm多线程编程篇 我的多线程W ...

  10. Android 下文件cannot execute - Permission denied

    安卓下执行交叉编译的可执行文件发现提示不允许. 原因是mount的方式问题,root后运行 su mount -o rw,remount /mnt/sdcard 就可以了 mount -o rw,re ...