设为首页 加入收藏

TOP

STL algorithm算法copy_if(8)
2015-07-20 17:43:58 来源: 作者: 【 】 浏览:3
Tags:STL algorithm 算法 copy_if
?

std::copy_if

template 
   
    
  OutputIterator copy_if (InputIterator first, InputIterator last,
                          OutputIterator result, UnaryPredicate pred);

   
Copy certain elements of range

Copies the elements in the range [first,last) for which pred returns true to the range beginning at result.

将符合要求的元素(对元素调用pred返回true的元素)复制到目标数组中。


The behavior of this function template is equivalent to:
1
2
3
4
5
6
7
8
9
10
11
12
13
template <class InputIterator, class OutputIterator, class UnaryPredicate>
  OutputIterator copy_if (InputIterator first, InputIterator last,
                          OutputIterator result, UnaryPredicate pred)
{
  while (first!=last) {
    if (pred(*first)) {
      *result = *first;
      ++result;
    }
    ++first;
  }
  return result;
}
?


Parameters

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Codeforces 464A No to Palindrom.. 下一篇uva 11235 Frequent values(游程..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·常用meta整理 | 菜鸟 (2025-12-25 01:21:52)
·SQL HAVING 子句:深 (2025-12-25 01:21:47)
·SQL CREATE INDEX 语 (2025-12-25 01:21:45)
·Shell 传递参数 (2025-12-25 00:50:45)
·Linux echo 命令 - (2025-12-25 00:50:43)