⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
📖 第 1 页 / 共 5 页
字号:
  "../complexity.html">linear time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="equal.html">equal</a><br>    <a href=    "lexicographical_compare_3.html">lexicographical_compare_3way</a><br>    <a href="mismatch.html">mismatch</a><br>    <a href="search.html">search</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    lexicographical_compare_3way  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  int lexicographical_compare_3way( iterator start1, iterator end1, iterator start2, iterator end2 );</pre>  <p>The lexicographical_compare_3way() function compares the first  range, defined by [<em>start1</em>,<em>end1</em>) to the second  range, defined by [<em>start2</em>,<em>end2</em>).</p>  <p>If the first range is lexicographically less than the second  range, this function returns a negative number. If the first range is  lexicographically greater than the second, a positive number is  returned. Zero is returned if neither range is lexicographically  greater than the other.</p>  <p>lexicographical_compare_3way() runs in <a href=  "../complexity.html">linear time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="lexicographical_compare.html">lexicographical_compare</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    lower_bound  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  iterator lower_bound( iterator first, iterator last,  const <a href="../containers.html">TYPE</a>&amp; val );  iterator lower_bound( iterator first, iterator last, const <a href="../containers.html">TYPE</a>&amp; val, CompFn f );</pre>  <p>The lower_bound() function is a type of <a href=  "binary_search.html">binary_search</a>(). This function searches for  the first place that <em>val</em> can be inserted into the ordered  range defined by <em>first</em> and <em>last</em> that will not mess  up the existing ordering.</p>  <p>The return value of lower_bound() is an iterator that points to  the location where <em>val</em> can be safely inserted. Unless the  comparison function <em>f</em> is specified, the &lt; operator is  used for ordering.</p>  <p>For example, the following code uses lower_bound() to insert the  number 7 into an ordered vector of integers:</p>  <pre class="example-code"> vector&lt;int&gt; nums; nums.push_back( -242 ); nums.push_back( -1 ); nums.push_back( 0 ); nums.push_back( 5 ); nums.push_back( 8 ); nums.push_back( 8 ); nums.push_back( 11 );           cout &lt;&lt; &quot;Before nums is: &quot;; for( unsigned int i = 0; i &lt; nums.size(); i++ ) {   cout &lt;&lt; nums[i] &lt;&lt; &quot; &quot;; } cout &lt;&lt; endl;             vector&lt;int&gt;::iterator result; int new_val = 7;                result = lower_bound( nums.begin(), nums.end(), new_val );              nums.insert( result, new_val );                 cout &lt;&lt; &quot;After, nums is: &quot;; for( unsigned int i = 0; i &lt; nums.size(); i++ ) {   cout &lt;&lt; nums[i] &lt;&lt; &quot; &quot;; } cout &lt;&lt; endl;            </pre>  <p>The above code produces the following output:</p>  <pre class="example-code"> Before nums is: -242 -1 0 5 8 8 11 After, nums is: -242 -1 0 5 7 8 8 11           </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="binary_search.html">binary_search</a><br>    <a href="equal_range.html">equal_range</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    make_heap  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  void make_heap( iterator start, iterator end );  void make_heap( iterator start, iterator end, StrictWeakOrdering cmp );</pre>  <p>The make_heap() function turns the given range of elements  [<em>start</em>,<em>end</em>) into a heap.</p>  <p>If the strict weak ordering comparison function object  <em>cmp</em> is given, then it is used instead of the &lt; operator  to compare elements.</p>  <p>make_heap() runs in <a href="../complexity.html">linear  time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="is_heap.html">is_heap</a><br>    <a href="pop_heap.html">pop_heap</a><br>    <a href="push_heap.html">push_heap</a><br>    <a href="sort_heap.html">sort_heap</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    max  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  const <a href="../containers.html">TYPE</a>&amp; max( const <a href="../containers.html">TYPE</a>&amp; x, const <a href="../containers.html">TYPE</a>&amp; y );  const <a href="../containers.html">TYPE</a>&amp; max( const <a href="../containers.html">TYPE</a>&amp; x, const <a href="../containers.html">TYPE</a>&amp; y, BinPred p );</pre>  <p>The max() function returns the greater of <em>x</em> and  <em>y</em>.</p>  <p>If the binary predicate <em>p</em> is given, then it will be used  instead of the &lt; operator to compare the two elements.</p>  <div class="related-examples-format">    Example code:  </div>  <div class="related-examples">    <p>For example, the following code snippet displays various uses of    the max() function:</p>    <pre class="example-code"> cout &lt;&lt; &quot;Max of 1 and 9999 is &quot; &lt;&lt; max( 1, 9999) &lt;&lt; endl; cout &lt;&lt; &quot;Max of &#39;a&#39; and &#39;b&#39; is &quot; &lt;&lt; max( &#39;a&#39;, &#39;b&#39;) &lt;&lt; endl; cout &lt;&lt; &quot;Max of 3.14159 and 2.71828 is &quot; &lt;&lt; max( 3.14159, 2.71828) &lt;&lt; endl;                </pre>    <p>When run, this code displays:</p>    <pre class="example-code"> Max of 1 and 9999 is 9999 Max of &#39;a&#39; and &#39;b&#39; is b Max of 3.14159 and 2.71828 is 3.14159          </pre>  </div>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="max_element.html">max_element</a><br>    <a href="min.html">min</a><br>    <a href="min_element.html">min_element</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    max_element  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  iterator max_element( iterator start, iterator end );  iterator max_element( iterator start, iterator end, BinPred p );</pre>  <p>The max_element() function returns an iterator to the largest  element in the range [<em>start</em>,<em>end</em>).</p>  <p>If the binary predicate <em>p</em> is given, then it will be used  instead of the &lt; operator to determine the largest element.</p>  <div class="related-examples-format">    Example code:  </div>  <div class="related-examples">    <p>For example, the following code uses the max_element() function    to determine the largest integer in an array and the largest    character in a vector of characters:</p>    <pre class="example-code"> int array[] = { 3, 1, 4, 1, 5, 9 }; unsigned int array_size = 6; cout &lt;&lt; &quot;Max element in array is &quot; &lt;&lt; *max_element( array, array+array_size) &lt;&lt; endl;               vector&lt;char&gt; v; v.push_back(&#39;a&#39;); v.push_back(&#39;b&#39;); v.push_back(&#39;c&#39;); v.push_back(&#39;d&#39;); cout &lt;&lt; &quot;Max element in the vector v is &quot; &lt;&lt; *max_element( v.begin(), v.end() ) &lt;&lt; endl;           </pre>    <p>When run, the above code displays this output:</p>    <pre class="example-code"> Max element in array is 9 Max element in the vector v is d               </pre>  </div>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="max.html">max</a><br>    <a href="min.html">min</a><br>    <a href="min_element.html">min_element</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    merge  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  iterator merge( iterator start1, iterator end1, iterator start2, iterator end2, iterator result );  iterator merge( iterator start1, iterator end1, iterator start2, iterator end2, iterator result, StrictWeakOrdering cmp );</pre>  <p>The merge() function combines two sorted ranges  [<em>start1</em>,<em>end1</em>) and [<em>start2</em>,<em>end2</em>)  into a single sorted range, stored starting at <em>result</em>. The  return value of this function is an iterator to the end of the merged  range.</p>  <p>If the strict weak ordering function object <em>cmp</em> is given,  then it is used in place of the &lt; operator to perform comparisons  between elements.</p>  <p>merge() runs in <a href="../complexity.html">linear time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="inplace_merge.html">inplace_merge</a><br>    <a href="set_union.html">set_union</a><br>    <a href="sort.html">sort</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    min  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  const <a href="../containers.html">TYPE</a>&amp; min( const <a href="../containers.html">TYPE</a>&amp; x, const <a href="../containers.html">TYPE</a>&amp; y );  const <a href="../containers.html">TYPE</a>&amp; min( const <a href="../containers.html">TYPE</a>&amp; x, const <a href="../containers.html">TYPE</a>&amp; y, BinPred p );</pre>  <p>The min() function, unsurprisingly, returns the smaller of  <em>x</em> and <em>y</em>.</p>  <p>By default, the &lt; operator is used to compare the two elements.  If the binary predicate <em>p</em> is given, it will be used  instead.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="max.html">max</a><br>    <a href="max_element.html">max_element</a><br>    <a href="min_element.html">min_element</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    min_element  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  iterator min_element( iterator start, iterator end );  iterator min_element( iterator start, iterator end, BinPred p );</pre>  <p>The min_element() function returns an iterator to the smallest  element in the range [<em>start</em>,<em>end</em>).</p>  <p>If the binary predicate <em>p</em> is given, then it will be used  instead of the &lt; operator to determine the smallest element.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="max.html">max</a><br>    <a href="max_element.html">max_element</a><br>    <a href="min.html">min</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    mismatch  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;  pair &lt;iterator1,iterator2&gt; mismatch( iterator start1, iterator end1, iterator start2 );  pair &lt;iterator1,iterator2&gt; mismatch( iterator start1, iterator end1, iterator start2, BinPred p );</pre>  <p>The mismatch() function compares the elements in the range defined  by [<em>start1</em>,<em>end1</em>) to the elements in a range of the  same size starting at <em>start2</em>. The return value of mismatch()  is the first location where the two ranges differ.</p>  <p>If the optional binary predicate <em>p</em> is given, then it is  used to compare elements from the two ranges.</p>  <p>The mismatch() algorithm runs in <a href=  "../complexity.html">linear time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="equal.html">equal</a><br>    <a href="find.html">find</a><br>    <a href=    "lexicographical_compare.html">lexicographical_compare</a><br>    <a href="search.html">search</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    next_permutation  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;algorithm&gt;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -