设为首页 加入收藏

TOP

STL algorithm算法find_first_of(18)
2015-07-20 17:42:22 来源: 作者: 【 】 浏览:1
Tags:STL algorithm 算法 find_first_of
?

std::find_first_of

  • C++98
  • C++11
  • equality (1)
    template 
             
              
       ForwardIterator1 find_first_of (InputIterator first1, InputIterator last1,
                                       ForwardIterator first2, ForwardIterator last2);
    
             
    predicate (2)
    template 
             
              
       ForwardIterator1 find_first_of (InputIterator first1, InputIterator last1,
                                       ForwardIterator first2, ForwardIterator last2,
                                       BinaryPredicate pred);
             
    Find element from set in range Returns an iterator to the first element in the range [first1,last1) that matches any of the elements in [first2,last2). If no such element is found, the function returns last1.

    返回一个迭代器,指向范围[first1,last1)中第一个匹配到[first2,last1)中的任一(并不要求全部匹配)元素。如果没有匹配的,则返回last1.

    例子:

    ?

    #include 
         
          
    #include 
          
            #include 
           
             #include 
            
              using namespace std; void findfirstof() { vector
             
               v1{1,2,3,4,5,6,3,4,9,8}; int arr[]={4,8}; array
              
                ai{77,88}; cout<
               
                例子:
                

    ?

    \ 可以看到,只要匹配到一个元素符号要求,就返回。

    The elements in [first1,last1) are sequentially compared to each of the values in [first2,last2) using operator== (or pred, in version (2)), until a pair matches.

    [first1,last1)中的每一个元素依次和[first2,last2)中的每一个元素匹配,直到一个匹配出现。

    The behavior of this function template is equivalent to:

    (仔细看下面的代码就能看出来)

    ?
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇HDOJ 3376 Matrix Again 下一篇线性表 - 带头结点的循环单链表

评论

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

·工业机器人TCP校准中 (2025-12-25 05:19:17)
·opc 通讯协议与 TCP (2025-12-25 05:19:15)
·labview中tcp/ip通信 (2025-12-25 05:19:13)
·新书介绍《Python数 (2025-12-25 04:49:47)
·怎么利用 Python 进 (2025-12-25 04:49:45)