PracticeDev/study_cpp/stl_list/stl_list.cpp

41 lines
883 B
C++
Raw Permalink Normal View History

2022-12-20 17:31:11 +08:00
/*************************************************************************
> File Name: stl_list.cpp
> Author: SongTL
> Mail: songtianlun@comleader.com.cn
> Created Time: 20200721 173759
************************************************************************/
#include <iostream>
#include <list>
#include <numeric>
#include <algorithm>
using namespace std;
typedef list<int> LISTINT;
typedef list<char> LISTCHAR;
int main()
{
LISTINT listOne;
LISTINT::interator i;
listOne.push_front(2);
listOne.push_front(1);
listOne.push_back(3);
listOne.push_back(4);
cout << "listOne.begin() --- listOne.end():" <<endl;
for(i = listOne.begin(); i != listOne.end(); ++i)
cout << *i << " ";
cout << endl;
LISTINT::reverse_interator ir;
for(ir = listOne.rbegin(); ir != listOne.rend();ir++)
cout << *ir << " ";
cout << endl;
return 1;
}