📄 find_end.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>find_end</title> <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table> <tr> <td> <div class="body-content"> <div class="header-box"> <a href="../index.html">cppreference.com</a> > <a href= "index.html">C++ Algorithms</a> > <a href= "find_end.html">find_end</a> </div> <div class="name-format"> find_end </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <algorithm> iterator find_end( iterator start, iterator end, iterator seq_start, iterator seq_end ); iterator find_end( iterator start, iterator end, iterator seq_start, iterator seq_end, BinPred bp );</pre> <p>The find_end() function searches for the sequence of elements denoted by <em>seq_start</em> and <em>seq_end</em>. If such a sequence if found between <em>start</em> and <em>end</em>, an iterator to the first element of the last found sequence is returned. If no such sequence is found, an iterator pointing to <em>end</em> is returned.</p> <p>If the binary predicate <em>bp</em> is specified, then it is used to when elements match.</p> <p>For example, the following code uses find_end() to search for two different sequences of numbers. The the first chunk of code, the last occurence of "1 2 3" is found. In the second chunk of code, the sequence that is being searched for is not found:</p> <pre class="example-code"> int nums[] = { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4 }; int* result; int start = 0; int end = 11; int target1[] = { 1, 2, 3 }; result = find_end( nums + start, nums + end, target1 + 0, target1 + 2 ); if( *result == nums[end] ) { cout << "Did not find any subsequence matching { 1, 2, 3 }" << endl; } else { cout << "The last matching subsequence is at: " << *result << endl; } int target2[] = { 3, 2, 3 }; result = find_end( nums + start, nums + end, target2 + 0, target2 + 2 ); if( *result == nums[end] ) { cout << "Did not find any subsequence matching { 3, 2, 3 }" << endl; } else { cout << "The last matching subsequence is at: " << *result << endl; } </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="adjacent_find.html">adjacent_find</a><br> <a href="find.html">find</a><br> <a href="find_first_of.html">find_first_of</a><br> <a href="find_if.html">find_if</a><br> <a href="search_n.html">search_n</a> </div> </div> </td> </tr> </table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -