STL-deque 双端数组简析
1 #include <iostream> 2 #include <deque> 3 4 using namespace std; 5 6 int main() 7 { 8 // 插入 9 deque<int> de; 10 for(int i=0;i<5;++i) 11 { 12 de.push_back(i); 13 } 14 15 for(int i=1;i<=5;++i) 16 { 17 de.push_front(i*10); 18 } 19 20 for(deque<int>::iterator it=de.begin();it!=de.end();++it) 21 { 22 cout<<*it<<" "; 23 } 24 cout<<endl; 25 26 // 删除 27 de.pop_back(); 28 de.pop_front(); 29 for(deque<int>::iterator it=de.begin();it!=de.end();++it) 30 { 31 cout<<*it<<" "; 32 } 33 cout<<endl; 34 35 // 求当前迭代器位置 36 for(deque<int>::iterator it=de.begin();it!=de.end();++it) 37 { 38 cout<<distance(de.begin()