首页 > 其他 > 详细

顺序容器

时间:2015-06-01 00:45:23      阅读:123      评论:0      收藏:0      [点我收藏+]

示例:

  

 1 #include <iostream>
 2 #include <vector>
 3 #include <list>
 4 #include <deque>
 5 
 6 using namespace std;
 7 int main()
 8 {
 9     vector<int> a;
10     list<int>   b;
11     deque<int>  c;
12 
13     vector<int>::size_type      a1;
14     vector<int>::iterator       a2;
15     vector<int>::const_iterator a3;
16     vector<int>::reverse_iterator a4;
17     vector<int>::const_reverse_iterator a5;
18     vector<int>::difference_type a6;
19     vector<int>::value_type      a7;
20     vector<int>::reference       a8;
21     vector<int>::const_reference a9;
22 
23     list<int>::size_type        b1;
24     list<int>::iterator         b2;
25     list<int>::const_iterator   b3;
26     list<int>::reverse_iterator b4;
27     list<int>::reverse_iterator b4;
28     list<int>::const_reverse_iterator b5;
29     list<int>::difference_type b6;
30     list<int>::value_type      b7;
31     list<int>::reference       b8;
32     list<int>::const_reference b9;
33 
34     deque<int>::size_type       c1;
35     deque<int>::iterator            c2;
36     deque<int>::const_iterator   c3;
37     deque<int>::reverse_iterator c4;
38     deque<int>::const_reverse_iterator c5;
39     deque<int>::difference_type c6;
40     deque<int>::value_type      c7;
41     deque<int>::reference       c8;
42     deque<int>::const_reference c9;
43 
44     a.push_back(10);
45     a.push_back(20);
46     a.push_back(30);
47     a.push_back(40);
48     for(vector<int>::size_type i=0; i<a.size();++i){
49         cout << a[i] << endl;
50     }
51     c.push_back(10);
52     c.push_back(20);
53     c.push_back(30);
54     for(deque<int>::size_type ii=0; ii<c.size();++i){  //size_type,而不是用int类型
55         cout << c[ii] << endl;
56     }
57 
58     for(deque<int>::reverse_iterator iii=c.rbegin();  //反向迭代器
59         iii != c.rend();iii--)
60     {
61     }
62     return 0;
63 }

 

顺序容器

原文:http://www.cnblogs.com/chris-cp/p/4542973.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!