vector的基本操作简析
vector <int >myvec;
myvec.pop_back();
insert:
注意是在迭代器位置之前进行插入操作;
1)myvec(myvec.begin(),5);
2)myvec(myvec.begin(),4,5);
3)myvec.insert(myvec.begin()+2,another.begin(),another.end());
erase:
// set some values (from 1 to 10)
for (int i=1; i<=10; i++) myvector.push_back(i);
// erase the 6th element
myvector.erase (myvector.begin()+5);//删除单个元素
// erase the first 3 elements:
myvector.erase (myvector.begin(),myvector.begin()+3);
//注意删除范围时是一个左闭右开的区间;
swap 交换两个容器中的值,跟map一样;