【C++进阶:STL常见性质2】

 

一般STL函数接收迭代器参数的规则为:[it1, it2) 左闭右开区间;

vector<int> scores;

scores.erase(scores.begin(),scores.end());

一般.end()指向容器结尾的下一个元素,称为超尾元素;

scores.insert(score.end(),new_score.begin()+1,new_score.end())即将new_score第2个到最后一个元素添加到score的末尾;

排序;

sort(score.begin(),score.end());

 

for遍历:

for_each(scores.begin(),scores.end(),show)

void show(const int &rr){

  cout<<rr<<endl;

}

遍历scores的每一个元素,并且把参数传给show;

posted @ 2019-03-14 10:28  Joel_Wang  阅读(132)  评论(0编辑  收藏  举报