国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

c++征途

2019-11-11 02:26:01
字體:
來源:轉載
供稿:網友

本人菜鳥近來學習c++,看書時看到一個如下的函數,想將其改成泛型算法但在刪除的地方產生了疑惑vector的erase的刪除是如何實現的而我僅僅依靠泛型指針能否實現刪除操作呢?

//vector<int> sub_vec(const vector<int> &vec ,const int &value)//{// vector<int> local_vec(vec);// sort(local_vec.begin(),local_vec.end());// vector<int>::iterator iter = find_if(local_vec.begin(),local_vec.end(),bind2nd(greater<int>(),value));// local_vec.erase(iter,local_vec.end());// return local_vec;//}

修改后

template<typename inputIterator,typename outputIterator,typename elemType>outputIterator sub_vec(inputIterator first,inputIterator end,outputIterator ofirst,const elemType &value){/*if(first==NULL&&end==NULL&&ofirst==NULL)return NULL;*/outputIterator at = ofirst;while(first!=end) //復制{  *at++ = *first++;}outputIterator oend = at;sort(ofirst,oend);outputIterator iter = find_if(ofirst,oend,bind2nd(greater<int>(),value)); for(;oend != iter;--oend){at = oend;--at;   cout<<"delete value:"<<*at<<endl;   ?????}return oend;

 }


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 嘉峪关市| 天水市| 梨树县| 通州区| 鄂托克旗| 长葛市| 阿尔山市| 华宁县| 安岳县| 铜山县| 武汉市| 汶川县| 探索| 循化| 且末县| 诏安县| 罗甸县| 松滋市| 启东市| 塔城市| 威远县| 图们市| 沁阳市| 裕民县| 碌曲县| 鄂伦春自治旗| 福贡县| 凤阳县| 克什克腾旗| 阜城县| 洛扎县| 台东市| 教育| 嘉峪关市| 博白县| 台山市| 卓资县| 三门县| 彭泽县| 民丰县| 永年县|