list的部分用法
来源:互联网 发布:锐捷交换机查看mac表 编辑:程序博客网 时间:2024/05/01 08:09
#include <iostream>
#include <algorithm>
#include <list>
#include <iterator>
#include <string>
using namespace std;
template<typename type>
void printlist(const type& elem)
{
static int c = 0;
if(c%4 == 0)
cout << endl;
cout << elem << "/t";
c++;
}
int main(void)
{
list<int> coll_1;
list<int> coll_2;
for(int i = 0; i < 20; ++i)
{
if(i%2 == 0)
coll_1.push_back(i);
else
coll_2.push_front(i);
}
cout << "coll_1: " ;
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:";
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_1.splice(coll_1.begin(), coll_2);
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:" ;
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_2.assign( find(coll_1.begin(), coll_1.end(), 3),
coll_1.end() );
coll_1.sort();
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:" ;
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_2.sort();
coll_1.merge(coll_2);
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:" ;
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_1.unique();
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
return 0;
}
#include <algorithm>
#include <list>
#include <iterator>
#include <string>
using namespace std;
template<typename type>
void printlist(const type& elem)
{
static int c = 0;
if(c%4 == 0)
cout << endl;
cout << elem << "/t";
c++;
}
int main(void)
{
list<int> coll_1;
list<int> coll_2;
for(int i = 0; i < 20; ++i)
{
if(i%2 == 0)
coll_1.push_back(i);
else
coll_2.push_front(i);
}
cout << "coll_1: " ;
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:";
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_1.splice(coll_1.begin(), coll_2);
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:" ;
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_2.assign( find(coll_1.begin(), coll_1.end(), 3),
coll_1.end() );
coll_1.sort();
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:" ;
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_2.sort();
coll_1.merge(coll_2);
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
cout << "coll_2:" ;
for_each(coll_2.begin(), coll_2.end(),
printlist<int>);
cout << endl;
coll_1.unique();
cout << "coll_1: ";
for_each(coll_1.begin(), coll_1.end(),
printlist<int>);
cout << endl;
return 0;
}
- list的部分用法
- List的部分方法
- allocarors的部分用法
- static_cast 的部分用法
- extern的部分用法
- Fragment的部分用法
- jsp的部分用法
- Restrictions的部分用法
- PureLayout的部分用法
- CListCtrl的部分用法
- pandas的部分用法
- List Control的用法:
- list control的用法
- list的用法
- list control的用法
- list control的用法
- C++ List的用法
- java List的用法
- 关于UTF8,UTF16,UTF32,UTF16-LE,UTF16-BE
- Eclipse+JBoss组合的介绍
- 项目工作小结之字符串处理的几个方法
- http://sigunix.cwru.edu/pub/cygwin/ftp/release/jpeg/
- 人生启示录
- list的部分用法
- 工作流管理系统
- 一种简便实效的配置文件读写方法
- 用四层结构方法开发信息管理系统
- VS.NET 2003 控件命名规范
- 控制MDI窗口的,最大化.最小化按钮!
- 石头与佛
- 常用SQL语句
- 有用的链接