替换元素(replace,replace_if,replace_copy,replace_copy_if)
2024-10-19 00:45:48
replace
审阅range中的每个元素,把old_value替换为new_value
template <class ForwardIterator,class T>
void replace(ForwardIterator first,ForwardIterator last,const T& old_value,const T& new_value);
replace_if
把pred(*i)为true的替换为new_value,为false的不影响
template <class ForwardIterator,class Predicate,class T>
void replace(ForwardIterator first,ForwardIterator last,Predicate pred,const T& new_value);
replace_copy
为replace的变形
- 将元素复制到result中
- 先copy之后再replace
template <class ForwardIterator,class OutputIterator,class T>
OutputIterator replace_copy(ForwardIterator first,ForwardIterator last,OutputIterator result,const T& old_value,const T& new_value);
replace_copy_if
为replace_if的变形
- 先copy之后再replace_if
- 不能作用于单一的(就地)replace
template <class ForwardIterator,class OutputIterator,class Predicate,class T>
OutputIterator replace_copy_if(ForwardIterator first,ForwardIterator last,OutputIterator result,Predicate pred,const T& new_value);
最新文章
- 关于前端CSS预处理器Sass的小知识!
- 轻松自动化---selenium-webdriver(python) (六)
- self&;super
- Position a child div relative to parent container in CSS: [设置 子DIV位置 跟 父DIV相关联]
- jqgrid单元格中增加按钮
- CentOS7_RAID5_LVM_SAMBA
- Word Search [LeetCode]
- python字典copy()方法
- web切图的几个快捷键及总结
- 【DP】捡苹果
- Centos环境下安装mongoDB
- 从码农到技术总监分享Leader经验
- C++算法之大数加法计算的代码
- C#通过COM组件操作IE浏览器(三):了解IHTMLDocument2
- Java基础(变量数&;常量&;据类型&;类型转换)
- PHP工程师笔试题
- 设置tab标签页 遮挡部分
- nyoj 数独
- poj3680
- libevent文档学习(一)多线程接口和使用