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的第二个序列中元素个数必须大于等于第一个序列中元素个数。

  • 相关阅读:
    07_Go语言 ( 切片)
    06_Go语言( 数组)
    05_Go语言( 流程控制)
    04_Go语言( 运算符)
    02_Go语言(变量和常量)
    01_Go语言(环境的搭建)
    云电脑直播简单指南
    统信UOS共享打印机配置
    #插头dp#洛谷 5074 Eat the Trees
    #状压dp#洛谷 3959 [NOIP2017 提高组] 宝藏
  • 原文地址:https://www.cnblogs.com/freewater/p/2946746.html
Copyright © 2011-2022 走看看