c++征途
来源:互联网 发布:caxa2015破解软件 编辑:程序博客网 时间:2024/04/20 23:13
本人菜鸟近来学习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;
}
- Objective-C征途:BOOL Party
- Objective-C 征途:String Party
- 征途
- Objective-C征途:Hello Objective-C
- IOS征途之c语言-C语言关键字
- IOS征途之c语言-C语言标示符
- IOS征途之c语言-C语言注释
- IOS征途之c语言-C语言数据类型
- IOS征途之c语言-C语言中的常量
- IOS征途之c语言-C语言中的变量
- IOS征途之c语言-C语言中的scanf函数
- 开始征途
- 《征途》=?
- 征途洪峰
- 大学征途
- 前途,征途
- 【征途怀旧】
- JavaScript征途
- sqlmapconfig.xml
- calligraphy(高效加载字体包)使用方法
- html标签中文字空心
- react学习心得(1)
- Linux中zip压缩和unzip解压缩命令详解
- c++征途
- Commandos (UVA-11463)
- liferay中自定义字段得到Group对象
- 一个字符串中可能包括a-z中的多个字符,如有重复,求出现最多次数的那个字符及次数,如有多个重复的则都求出
- 自定义内容提供者
- 点击Android SDK Manager时提示找不到路径
- 读书《C与指针》笔记(未完,持续更新与整理中)
- VC++实现任务栏托盘
- 大数据处理分析的六大最好工具