splice函数
来源:互联网 发布:广电网络宽带资费 编辑:程序博客网 时间:2024/05/16 06:00
http://www.cplusplus.com/reference/list/list/splice/
void splice (iterator position, list& x);
void splice (iterator position, list& x, iterator i);
void splice (iterator position, list& x, iterator first, iterator last);
The first version (1) transfers all the elements of x into the container.
The second version (2) transfers only the element pointed by i from x into the container.
The third version (3) transfers the range [first,last) from x into the container.
// splicing lists#include <iostream>#include <list>int main (){ std::list<int> mylist1, mylist2; std::list<int>::iterator it; // set some initial values: for (int i=1; i<=4; ++i) mylist1.push_back(i); // mylist1: 1 2 3 4 for (int i=1; i<=3; ++i) mylist2.push_back(i*10); // mylist2: 10 20 30 it = mylist1.begin(); ++it; // points to 2 mylist1.splice (it, mylist2); // mylist1: 1 10 20 30 2 3 4 // mylist2 (empty) // "it" still points to 2 (the 5th element) mylist2.splice (mylist2.begin(),mylist1, it); // mylist1: 1 10 20 30 3 4 // mylist2: 2 // "it" is now invalid. it = mylist1.begin(); std::advance(it,3); // "it" points now to 30 mylist1.splice ( mylist1.begin(), mylist1, it, mylist1.end()); // mylist1: 30 3 4 1 10 20 std::cout << "mylist1 contains:"; for (it=mylist1.begin(); it!=mylist1.end(); ++it) std::cout << ' ' << *it; std::cout << '\n'; std::cout << "mylist2 contains:"; for (it=mylist2.begin(); it!=mylist2.end(); ++it) std::cout << ' ' << *it; std::cout << '\n'; return 0;}
Edit & Run
0 0
- splice函数
- list::splice()函数详解
- perl的splice函数
- list::splice()函数详解
- list 的 splice 函数
- list::splice()函数详解
- list::splice()函数详解
- javaScript splice函数
- list::splice()函数详解
- list::splice()函数详解
- js的splice() 函数
- javascript splice()函数
- perl函数splice的用法
- splice() 函数的使用【JavaScript】
- JS数组之splice函数
- js数组的splice函数
- c++ list 容器splice函数
- c++ container list function ----splice(list的成员函数splice)
- 30个最常用CSS选择器解析
- 第五周项目一体验常成员函数
- 三维坐标和矩阵的关系
- Eclipse直接完成JAVA调用C/C++ (Eclipse上使用CDT结合MinGW)
- Android基础——主线程不能进行网络请求小结
- splice函数
- C++指向类成员的指针的使用(详细介绍)
- java系统属性properties介绍System.getProperty()参数大全
- Cannot change version of project facet Dynamic Web Module to 2.5最好的解决方法
- Wrangling Complex Spreadsheet Column Headers
- 反射机制
- MySql存储过程创建学习总结
- 第六周项目一 深复制体验2
- struts2中一个action中实现多个功能