std::experimental::ranges::find_first_of
Defined in header <experimental/ranges/algorithm>
|
||
template< InputIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2, class Proj1 = ranges::identity, class Proj2 = ranges::identity, |
(1) | (ranges TS) |
template< InputRange R1, ForwardRange R2, class Proj1 = ranges::identity, class Proj2 = ranges::identity, |
(2) | (ranges TS) |
[
first1,
last1)
for any of the elements in the range [
first2,
last2)
, after projecting the ranges with proj1 and proj2 respectively. The projected elements are compared using pred.Contents |
[edit] Parameters
first1, last1 | - | the range of elements to examine |
r1 | - | the range of elements to examine |
first2, last2 | - | the range of elements to search for |
r2 | - | the range of elements to search for |
pred | - | predicate to use to compare the projected elements with |
proj1 | - | projection to apply to the elements in the first range |
proj2 | - | projection to apply to the elements in the second range |
[edit] Return value
Iterator to the first element in the range [
first1,
last1)
that is equal to an element from the range [
first2,
last2)
after projection. If no such element is found, an iterator comparing equal to last1 is returned.
[edit] Complexity
At most (S * N)
applications of the predicate and each projection, where S = distance(last2 - first2) and N = last1 - first1.
[edit] Possible implementation
template<InputIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2, class Proj1 = ranges::identity, class Proj2 = ranges::identity, IndirectRelation<projected<I1, Proj1>, projected<I2, Proj2>> Pred = ranges::equal_to<>> I1 find_first_of(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = Pred{}, Proj1 proj1 = Proj1{}, Proj2 proj2 = Proj2{}) { for (; first1 != last1; ++first1) for (ForwardIt it = first2; it != last2; ++it) if (ranges::invoke(pred, ranges::invoke(proj1, *first1), ranges::invoke(proj2, *it))) return first1; return first1; } |
[edit] Example
This section is incomplete Reason: no example |
[edit] See also
searches for any one of a set of elements (function template) | |
finds the first element satisfying specific criteria (function template) |