/* * ===================================================================================== * * Filename: list.cpp * * Description: test for STL list * * Version: 1.0 Created: 2010/1/17 16:30:27 Revision: none Compiler: * g++ * * Author: bird Company: nbut * * ===================================================================================== */ #include<iostream> #include <list> #include <algorithm> using namespace std; int main ( int argc, char *argv[] ){ list<int > ls; //length; cout <<"first length is:"<< ls.size() << endl; //insert; list<int >::iterator iter =ls.begin(); ls.insert(iter,0); cout <<"after insert 0 ,length is:"<< ls.size() << endl; int n=10; while(n--){ ls.push_back(n); } cout <<"after insert 10 int,length is:"<< ls.size() << endl; //find iter=find(ls.begin(),ls.end(),8); cout <<"the item find is:"<< *(iter) << endl; //get; cout <<"the item get is:"<< *(ls.begin()) << endl; //delete; ls.erase(ls.begin()); cout <<"after delete, the length is:"<< ls.size() << endl; return EXIT_SUCCESS; } /* ---------- end of function main ---------- */
STL list for linklist
最新推荐文章于 2022-04-03 18:00:00 发布