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

    equal

    Compares two ranges element by element either for equality or equivalence in a sense specified by a binary predicate.

    template<class InputIterator1, class InputIterator2>
       bool equal(
          InputIterator1 _First1, 
          InputIterator1 _Last1, 
          InputIterator2 _First2
       );
    template<class InputIterator1, class InputIterator2, class BinaryPredicate>
       bool equal(
          InputIterator1 _First1, 
          InputIterator1 _Last1, 
          InputIterator2 _First2, 
          BinaryPredicate _Comp
       );
     
    Return Value

    true if and only if the ranges are identical or equivalent under the binary predicate when compared element by element; otherwise, false.

     
    Remarks

    The range to be searched must be valid; all pointers must be dereferenceable and the last position is reachable from the first by incrementation.

    The time complexity of the algorithm is linear in the number of elements contained in the range.

    The operator== used to determine the equality between elements must impose an equivalence relation between its operands.

    注:如果两个序列在[first,last)区间内相等,equal()返回true。如果第二序列的元素比较多,多出来的元素不予考虑。因此,如果我们希望保证两个序列完全相等,必须先判断其元素个数是否相等。

    if( vec1.size() == vec2.size() ) && equal( vec1.begin(), vec1.end(), vec2.begin() ) ){...}

    equal的第二个序列中元素个数必须大于等于第一个序列中元素个数。

  • 相关阅读:
    android 限定符参考
    Fragment生命周期
    碎片和活动之间通信
    Fragment碎片的使用
    使用Intent传值及回传值
    Calendar 获取年 月 日 时 分 秒
    Python函数:2018-07-30
    Python 字符串 2018-07-27
    Python 异常 2018-08-01
    __future__ 模块 2018-08-09
  • 原文地址:https://www.cnblogs.com/freewater/p/2946746.html
Copyright © 2011-2022 走看看