std::experimental::ranges::find_end
| Technical Specification | ||||
| Filesystem library (filesystem TS) | ||||
| Library fundamentals (library fundamentals TS) | ||||
| Library fundamentals 2 (library fundamentals TS v2) | ||||
| Library fundamentals 3 (library fundamentals TS v3) | ||||
| Extensions for parallelism (parallelism TS) | ||||
| Extensions for parallelism 2 (parallelism TS v2) | ||||
| Extensions for concurrency (concurrency TS) | ||||
| Extensions for concurrency 2 (concurrency TS v2) | ||||
| Concepts (concepts TS) | ||||
| Ranges (ranges TS) | ||||
| Reflection (reflection TS) | ||||
| Mathematical special functions (special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Non-modifying sequence operations | ||||||||||||||||||
| ||||||||||||||||||
| Modifying sequence operations | ||||||||||||||||||
| Partitioning operations | ||||||||||||||||||
| Sorting operations | ||||||||||||||||||
| Binary search operations | ||||||||||||||||||
| Set operations (on sorted ranges) | ||||||||||||||||||
| Heap operations | ||||||||||||||||||
| Minimum/maximum operations | ||||||||||||||||||
| Permutations | ||||||||||||||||||
| Defined in header <experimental/ranges/algorithm>
|
||
| template< ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2, class Proj = ranges::identity, |
(1) | (ranges TS) |
| template< ForwardRange R1, ForwardRange R2, class Proj = ranges::identity, IndirectRelation<ranges::iterator_t<R2>, |
(2) | (ranges TS) |
[first2, last2) in the range [first1, last1) (after projection with proj). 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
| 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 compare the elements |
| proj | - | projection to apply to the elements in the first range |
[edit] Return value
Iterator to the beginning of last occurrence of the sequence [first2, last2) in range [first1, last1) (after projection with proj).
If [first2, last2) is empty or if no such sequence is found, an iterator that compares equal to last1 is returned.
[edit] Complexity
At most S * (N - S + 1) applications of the predicate and projection, where S = last2 - first2 and N = last1 - first1.
[edit] Notes
The projection is only applied to the range [first1, last1).
[edit] Possible implementation
template<ForwardIterator I1, Sentinel<I1> S1, ForwardIterator I2, Sentinel<I2> S2, class Proj = ranges::identity, IndirectRelation<I2, ranges::equal_to<>> I1 find_end(I1 first1, S1 last1, I2 first2, S2 last2, Pred pred = Pred{}, Proj proj = Proj{}) { I1 result = ranges::next(first1, last1); if (first2 == last2) return result; while (true) { I1 new_result = ranges::search(first1, last1, first2, last2, pred, proj); if (new_result == last1) break; else { result = new_result; first1 = result; ++first1; } } return result; } |
[edit] Example
| This section is incomplete Reason: no example |
[edit] See also
| finds the last sequence of elements in a certain range (function template) [edit] | |
| searches for a range of elements (function template) [edit] | |
| returns true if one set is a subset of another (function template) [edit] | |
| finds the first two adjacent items that are equal (or satisfy a given predicate) (function template) [edit] | |
| finds the first element satisfying specific criteria (function template) [edit] | |
| searches for any one of a set of elements (function template) [edit] | |
| searches for a number consecutive copies of an element in a range (function template) [edit] |