您的位置:首页 > 编程语言 > C语言/C++

C++ STL List

2011-04-16 08:21 246 查看
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<list>
/********************************************************
list的操作函数
list 的特征
使用双向链表来管理元素
不支持随即存储
任何位置上执行元素的安插与移除到很快
安插与删除不会找出指向其他元素的各个pointers,references失效

*********************************************************/

using namespace std;

int main()
{
//int a[]={1,2,5,64,6,67,4};
list<int>coll;
//creat list
for(int t=0;t<6;t++)
coll.push_back(t);

//move frist element to the end
//coll.splice(coll.end,coll,coll.begin());
coll.sort();
cout<<coll.size()<<endl;
//remove duplicates
coll.unique();
cout<<coll.front();

if(!coll.empty())
{
cout<<coll.back();

}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: