zoukankan      html  css  js  c++  java
  • STL: replace

    replace

    Examines each element in a range and replaces it if it matches a specified value.

     
    template<class ForwardIterator, class Type> 
       void replace( 
          ForwardIterator _First,  
          ForwardIterator _Last, 
          const Type& _OldVal,  
          const Type& _NewVal 
       );

    replace_if

    Examines each element in a range and replaces it if it satisfies a specified predicate.

    template<class ForwardIterator, class Predicate, class Type> 
       void replace_if( 
          ForwardIterator _First,  
          ForwardIterator _Last, 
          Predicate _Pred,  
          const Type& _Val 
       );

    replace_copy

    Examines each element in a source range and replaces it if it matches a specified value while copying the result into a new destination range.

    template<class InputIterator, class OutputIterator, class Type> 
       OutputIterator replace_copy( 
          InputIterator _First,  
          InputIterator _Last,  
          OutputIterator _Result, 
          const Type& _OldVal,  
          const Type& _NewVal 
       );

    replace_copy_if

    Examines each element in a source range and replaces it if it satisfies a specified predicate while copying the result into a new destination range.

    template<class InputIterator, class OutputIterator, class Predicate, class Type> 
       OutputIterator replace_copy_if( 
          InputIterator _First,  
          InputIterator _Last,  
          OutputIterator _Result,  
          Predicate _Pred,  
          const Type& _Val 
       );
  • 相关阅读:
    leetcode-38.报数
    leetcode-35.搜索插入位置
    leetcode-27.移除元素
    leetcode-26.删除重复数组中的重复项
    leetcode-20.有效的括号
    leetcode-973最接近原点的K个点
    leetcode-14最长公共前缀
    leetcode-13罗马字符转整数
    MFC俄罗斯方块
    leetcode-9.回文数(水仙花数)
  • 原文地址:https://www.cnblogs.com/freewater/p/2953620.html
Copyright © 2011-2022 走看看