#include <iostream>
#include <string>
#include <list>
typedef std::list<std::string> LISTSTR ;
int main()
{
LISTSTR test;
test.push_back("back");
test.push_front("middle");
test.push_front("front");
LISTSTR::iterator it=test.begin();
for(;it!=test.end();it++)
{
std::cout << *it << std::endl;
}
LISTSTR::reverse_iterator rit=test.rbegin();
for(;rit!=test.rend();rit++)
{
std::cout << *rit << std::endl;
}
std::cout << std::endl;
std::cout << test.front() << std::endl;
std::cout << *test.begin() << std::endl;
std::cout << test.back() << std::endl;
std::cout << *(test.rbegin())<< std::endl;
test.pop_front() ;
test.pop_back() ;
std::cout << test.front() << std::endl;
return 0;
}
list容器
最新推荐文章于 2024-06-03 09:14:44 发布