Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::ranges::find,std::experimental::ranges::find_if,std::experimental::ranges::find_if_not

      From cppreference.com
      <cpp‎ |experimental‎ |ranges
       
       
       
       
      Algorithms library
      Non-modifying sequence operations
      findfind_iffind_if_not
                                    
      Modifying sequence operations
                                    
      Partitioning operations
      Sorting operations
      Binary search operations
      Set operations (on sorted ranges)
                                    
      Heap operations
      Minimum/maximum operations
      Permutations
       
      template< InputIterator I, Sentinel<I> S,class T,class Proj=ranges::identity>

          requires IndirectRelation<ranges::equal_to<>,projected<I, Proj>,const T*>

      I find( I first, S last,const T& value, Proj proj= Proj{});
      (1)(ranges TS)
      template< InputRange R,class T,class Proj=ranges::identity>

          requires IndirectRelation<ranges::equal_to<>,
                                   projected<ranges::iterator_t<R>, Proj>,const T*>

      ranges::safe_iterator_t<R> find( R&& r,const T& value, Proj proj= Proj{});
      (2)(ranges TS)
      template< InputIterator I, Sentinel<I> S,class Proj=ranges::identity,

                IndirectUnaryPredicate<projected<I, Proj>> Pred>

      I find_if( I first, S last, Pred pred, Proj proj= Proj{});
      (3)(ranges TS)
      template< InputRange R,class Proj=ranges::identity,

                IndirectUnaryPredicate<projected<ranges::iterator_t<R>, Proj>> Pred>

      ranges::safe_iterator_t<R> find_if( R&& r, Pred pred, Proj proj= Proj{});
      (4)(ranges TS)
      template< InputIterator I, Sentinel<I> S,class Proj=ranges::identity,

                IndirectUnaryPredicate<projected<I, Proj>> Pred>

      I find_if_not( I first, S last, Pred pred, Proj proj= Proj{});
      (5)(ranges TS)
      template< InputRange R,class Proj=ranges::identity,

                IndirectUnaryPredicate<projected<ranges::iterator_t<R>, Proj>> Pred>

      ranges::safe_iterator_t<R> find_if_not( R&& r, Pred pred, Proj proj= Proj{});
      (6)(ranges TS)

      Returns the first element in the range[firstlast) that satisfies specific criteria:

      1)find searches for an element whose projected value is equal tovalue (i.e.,value==ranges::invoke(proj,*i)).
      3)find_if searches for an element for whose projected value predicatep returnstrue (i.e.,ranges::invoke(pred,ranges::invoke(proj,*i))) istrue).
      5)find_if_not searches for an element for whose projected value predicateq returnsfalse (i.e.,ranges::invoke(pred,ranges::invoke(proj,*i))) isfalse).
      2,4,6) Same as(1,3,5), but usesr as the source range, as if usingranges::begin(r) asfirst andranges::end(r) aslast.

      Notwithstanding the declarations depicted above, the actual number and order of template parameters for algorithm declarations is unspecified. Thus, if explicit template arguments are used when calling an algorithm, the program is probably non-portable.

      Contents

      [edit]Parameters

      first, last - the range of elements to examine
      r - the range of elements to examine
      value - value to compare the projected elements to
      pred - predicate to apply to the projected elements
      proj - projection to apply to the elements

      [edit]Return value

      Iterator to the first element satisfying the condition. If no such element is found, returns an iterator that compares equal tolast.

      [edit]Complexity

      At mostlast -first applications of the predicate and projection.

      [edit]Possible implementation

      First version
      template<InputIterator I, Sentinel<I> S,class T,class Proj=ranges::identity>    requires IndirectRelation<ranges::equal_to<>,projected<I, Proj>,const T*>I find(I first, S last,const T& value, Proj proj= Proj{}){for(; first!= last;++first)if(ranges::invoke(proj,*first)== value)break;return first;}
      Second version
      template<InputIterator I, Sentinel<I> S,class Proj=ranges::identity,         IndirectUnaryPredicate<projected<I, Proj>> Pred>I find_if(I first, S last, Pred pred, Proj proj= Proj{}){for(; first!= last;++first)if(ranges::invoke(pred,ranges::invoke(proj,*first)))break;return first;}
      Third version
      template<InputIterator I, Sentinel<I> S,class Proj=ranges::identity,         IndirectUnaryPredicate<projected<I, Proj>> Pred>I find_if_not(I first, S last, Pred pred, Proj proj= Proj{}){for(; first!= last;++first)if(!ranges::invoke(pred,ranges::invoke(proj,*first)))break;return first;}

      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      finds the first element satisfying specific criteria
      (function template)[edit]
      finds the first two adjacent items that are equal (or satisfy a given predicate)
      (function template)[edit]
      finds the last sequence of elements in a certain range
      (function template)[edit]
      searches for any one of a set of elements
      (function template)[edit]
      finds the first position where two ranges differ
      (function template)[edit]
      searches for a range of elements
      (function template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/ranges/algorithm/find&oldid=155244"

      [8]ページ先頭

      ©2009-2026 Movatter.jp