list

来源:互联网 发布:mysql innodb 分表 编辑:程序博客网 时间:2024/05/22 04:48

容器list的底层数据结构为链表,为非连续内存,不支持[]操作符,支持任意位置操作,下面的代码展示了list的使用方法:

#include<iostream>
#include<list>
using namespace std;

int main()
{
 list<char> l;
 char c;
 for( c='a';c<'z';++c)
 {
  l.push_back(c);
 }
    list<char>::const_iterator pos;
 for(pos=l.begin();pos!=l.end();++pos)
 {
  cout<<*pos<<" ";
 }

 return 0;
}