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 
   );

 

posted @ 2013-03-11 11:10  freewater  阅读(492)  评论(0编辑  收藏  举报