📄 equal.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>equal</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="equal.html">equal</a> </div> <div class="name-format"> equal </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <algorithm> bool equal( iterator start1, iterator end1, iterator start2 ); bool equal( iterator start1, iterator end1, iterator start2, BinPred p );</pre> <p>The equal() function returns true if the elements in two ranges are the same. The first range of elements are those between <em>start1</em> and <em>end1</em>. The second range of elements has the same size as the first range but starts at <em>start2</em>.</p> <p>If the binary predicate <em>p</em> is specified, then it is used instead of == to compare each pair of elements.</p> <p>For example, the following code uses equal() to compare two vectors of integers:</p> <pre class="example-code"> vector<int> v1; for( int i = 0; i < 10; i++ ) { v1.push_back( i ); } vector<int> v2; for( int i = 0; i < 10; i++ ) { v2.push_back( i ); } if( equal( v1.begin(), v1.end(), v2.begin() ) ) { cout << "v1 and v2 are equal" << endl; } else { cout << "v1 and v2 are NOT equal" << endl; } </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="find_if.html">find_if</a><br> <a href= "lexicographical_compare.html">lexicographical_compare</a><br> <a href="mismatch.html">mismatch</a><br> <a href="search.html">search</a> </div> </div> </td> </tr> </table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -