📄 all.html
字号:
"../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 <algorithm> 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 <algorithm> iterator lower_bound( iterator first, iterator last, const <a href="../containers.html">TYPE</a>& val ); iterator lower_bound( iterator first, iterator last, const <a href="../containers.html">TYPE</a>& 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 < 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<int> 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 << "Before nums is: "; for( unsigned int i = 0; i < nums.size(); i++ ) { cout << nums[i] << " "; } cout << endl; vector<int>::iterator result; int new_val = 7; result = lower_bound( nums.begin(), nums.end(), new_val ); nums.insert( result, new_val ); cout << "After, nums is: "; for( unsigned int i = 0; i < nums.size(); i++ ) { cout << nums[i] << " "; } cout << 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 <algorithm> 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 < 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 <algorithm> const <a href="../containers.html">TYPE</a>& max( const <a href="../containers.html">TYPE</a>& x, const <a href="../containers.html">TYPE</a>& y ); const <a href="../containers.html">TYPE</a>& max( const <a href="../containers.html">TYPE</a>& x, const <a href="../containers.html">TYPE</a>& 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 < 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 << "Max of 1 and 9999 is " << max( 1, 9999) << endl; cout << "Max of 'a' and 'b' is " << max( 'a', 'b') << endl; cout << "Max of 3.14159 and 2.71828 is " << max( 3.14159, 2.71828) << endl; </pre> <p>When run, this code displays:</p> <pre class="example-code"> Max of 1 and 9999 is 9999 Max of 'a' and 'b' 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 <algorithm> 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 < 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 << "Max element in array is " << *max_element( array, array+array_size) << endl; vector<char> v; v.push_back('a'); v.push_back('b'); v.push_back('c'); v.push_back('d'); cout << "Max element in the vector v is " << *max_element( v.begin(), v.end() ) << 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 <algorithm> 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 < 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 <algorithm> const <a href="../containers.html">TYPE</a>& min( const <a href="../containers.html">TYPE</a>& x, const <a href="../containers.html">TYPE</a>& y ); const <a href="../containers.html">TYPE</a>& min( const <a href="../containers.html">TYPE</a>& x, const <a href="../containers.html">TYPE</a>& 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 < 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 <algorithm> 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 < 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 <algorithm> pair <iterator1,iterator2> mismatch( iterator start1, iterator end1, iterator start2 ); pair <iterator1,iterator2> 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 <algorithm>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -