printDeque(d1);

 

//元素删除 尾部删除用pop_back();头部删除用pop_front(); 
//任意迭代位置或迭代区间上的元素删除用erase(&pos)/erase(&first, &last);删除所有元素用clear();
cout<<"d1.pop_front(): "<<endl;
d1.pop_front();
printDeque(d1);

cout
<<"d1.erase(d1.begin()+1): "<<endl;
d1.erase(d1.begin()
+1); //删除第2个元素d1[1]
printDeque(d1);

cout
<<"d1.erase(d1.begin(), d1.begin() + 2) = "<<endl;
d1.erase(d1.begin(), d1.begin() 
+ 2);
printDeque(d1);

cout
<<"d1.clear() :"<<endl;
d1.clear();
printDeque(d1);


//其它常用
cout<<"其它常用用法: "<<endl;
int flag = 0;
while(flag < 2)
}

 

 转帖自:http://www.cppblog.com/huyutian/articles/107459.html

相关文章:

  • 2021-08-20
  • 2021-12-17
  • 2021-06-04
  • 2021-12-02
猜你喜欢
  • 2022-12-23
  • 2022-01-20
  • 2021-07-11
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案