STL algorithm算法(02):all_of

函数调用形式:

template <class InputIterator, class UnaryPredicate>
  bool all_of (InputIterator first, InputIterator last, UnaryPredicate pred);
Test condition on all elements in range

针对范围内所有元素的检测条件

Returns true if pred returns true for all the elements in the range [first,last) or if the range is empty, and falseotherwise

如果所有元素的检测结果都为true,则函数返回true,否则,返回false。

The behavior of this function template is equivalent to:

函数的具体行为与如下类似:

template<class InputIterator, class UnaryPredicate>
  bool all_of (InputIterator first, InputIterator last, UnaryPredicate pred)
{
  while (first!=last) {
    if (!pred(*first)) return false;
    ++first;
  }
  return true;
}

Parameters

first, last
Input iterators to the initial and final positions in a sequence. The range used is  [first,last), which contains all the elements between  first and  last, including the element pointed by  first but not the element pointed by last.
输入的迭代器分别是序列的首位置和末位置。范围为[first,last),包括first指向的元素,但是不包括last指向的元素。
pred
Unary function that accepts an element in the range as argument and returns a value convertible to  bool. The value returned indicates whether the element fulfills the condition checked by this function.
The function shall not modify its argument.
This can either be a function pointer or a function object.
一元函数接收单个元素作为参数并检测该值是否符合条件。
这个函数不会因为单个元素发生变化(判断规则一致)。
这里也可以是一个指向函数对象的指针。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值