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

📄 all.html

📁 从www.CppReference.com打包的C++参考手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<hr>  <div class="name-format">    lower_bound  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  iterator lower_bound( const <a href="../containers.html">key_type</a>&amp; key );</pre>  <p>The lower_bound() function returns an iterator to the first  element which has a value greater than or equal to key.</p>  <p>lower_bound() runs in <a href="../complexity.html">logarithmic  time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="upper_bound.html">upper_bound</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    max_size  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  <strong>size_type</strong> max_size() const;</pre>  <p>The max_size() function returns the maximum number of elements  that the multimap can hold. The max_size() function should not be  confused with the <a href="size.html">size</a>() or (C++ Strings)  <a href="../cppstring/capacity.html">capacity</a>() functions, which  return the number of elements currently in the multimap and the the  number of elements that the multimap will be able to hold before more  memory will have to be allocated, respectively.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="size.html">size</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    Multimap constructors &amp; destructors  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  multimap();  multimap( const multimap&amp; c );  multimap( iterator begin, iterator end,            const key_compare&amp; cmp = Compare(), const allocator&amp; alloc = Allocator() );  ~multimap();</pre>  <p>Multimaps have several constructors:</p>  <ul>  <li>The default constructor takes no arguments, creates a new  instance of that multimap, and runs in <a  href="../complexity.html">constant time</a>.</li>  <li>The default copy constructor runs in <a href=  "../complexity.html">linear time</a> and can be used to create a new  multimap that is a copy of the given multimap <em>c</em>.</li>  <li>Multimaps can also be created from a range of elements defined by  <em>begin</em> and <em>end</em>.  When using this constructor, an  optional comparison function <em>cmp</em> and allocator  <em>alloc</em> can also be provided.</li>  </ul>  <p>The default destructor is called when the multimap should be  destroyed.</p>  <p>The template definition of multimaps requires that both a key  type and value type be supplied.  For example, you can instantiate a  multimap that maps strings to integers with this statement:</p>  <pre class="example-code">  multimap&lt;string,int&gt; m;</pre>  <p>You can also supply a comparison function and an allocator in the  template:</p>  <pre class="example-code">  multimap&lt;string,int,myComp,myAlloc&gt; m;</pre>  <p>For example, the following code uses a multimap to associate a  series of employee names with numerical IDs:</p>  <pre class="example-code">  multimap&lt;string,int&gt; m;  int employeeID = 0;  m.insert( pair&lt;string,int&gt;("Bob Smith",employeeID++) );  m.insert( pair&lt;string,int&gt;("Bob Thompson",employeeID++) );  m.insert( pair&lt;string,int&gt;("Bob Smithey",employeeID++) );  m.insert( pair&lt;string,int&gt;("Bob Smith",employeeID++) );  cout &lt;&lt; "Number of employees named 'Bob Smith': " &lt;&lt; m.count("Bob Smith") &lt;&lt; endl;  cout &lt;&lt; "Number of employees named 'Bob Thompson': " &lt;&lt; m.count("Bob Thompson") &lt;&lt; endl;  cout &lt;&lt; "Number of employees named 'Bob Smithey': " &lt;&lt; m.count("Bob Smithey") &lt;&lt; endl;  cout &lt;&lt; "Employee list: " &lt;&lt; endl;  for( multimap&lt;string, int&gt;::iterator iter = m.begin(); iter != m.end(); ++iter ) {    cout &lt;&lt; " Name: " &lt;&lt; iter-&gt;first &lt;&lt; ", ID #" &lt;&lt; iter-&gt;second &lt;&lt; endl;  }</pre>  <p>When run, the above code produces the following output.  Note  that the employee list is displayed in alphabetical order, because  multimaps are sorted associative containers:</p>  <pre class="example-code">  Number of employees named 'Bob Smith': 2  Number of employees named 'Bob Thompson': 1  Number of employees named 'Bob Smithey': 1  Employee list:   Name: Bob Smith, ID #0   Name: Bob Smith, ID #3   Name: Bob Smithey, ID #2   Name: Bob Thompson, ID #1</pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="count.html">count</a><br>    <a href="insert.html">insert</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    Multimap operators  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  multimap operator=(const multimap&amp; c2);  bool operator==(const multimap&amp; c1, const multimap&amp; c2);  bool operator!=(const multimap&amp; c1, const multimap&amp; c2);  bool operator&lt;(const multimap&amp; c1, const multimap&amp; c2);  bool operator&gt;(const multimap&amp; c1, const multimap&amp; c2);  bool operator&lt;=(const multimap&amp; c1, const multimap&amp; c2);  bool operator&gt;=(const multimap&amp; c1, const multimap&amp; c2);</pre>  <p>All of the C++ containers can be compared and assigned with the  standard comparison operators: ==, !=, &lt;=, &gt;=, &lt;, &gt;, and  =. Performing a comparison or assigning one multimap to another takes  <a href="../complexity.html">linear time</a>.</p>  <p>Two multimaps are equal if:</p>  <ol>    <li>Their size is the same, and</li>    <li>Each member in location i in one multimap is equal to the the    member in location i in the other multimap.</li>  </ol>  <p>Comparisons among multimaps are done lexicographically.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="multimap_constructors.html">Multimap Constructors</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    rbegin  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  <a href="../iterators.html">reverse_iterator</a> rbegin();  const_<a href="../iterators.html">reverse_iterator</a> rbegin() const;</pre>  <p>The rbegin() function returns a <a href=  "../iterators.html">reverse_iterator</a> to the end of the current  multimap.</p>  <p>rbegin() runs in <a href="../complexity.html">constant  time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="begin.html">begin</a><br>    <a href="end.html">end</a><br>    <a href="rend.html">rend</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    rend  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  <a href="../iterators.html">reverse_iterator</a> rend();  const_<a href="../iterators.html">reverse_iterator</a> rend() const;</pre>  <p>The function rend() returns a <a href=  "../iterators.html">reverse_iterator</a> to the beginning of the  current multimap.</p>  <p>rend() runs in <a href="../complexity.html">constant time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="begin.html">begin</a><br>    <a href="end.html">end</a><br>    <a href="rbegin.html">rbegin</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    size  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  <strong>size_type</strong> size() const;</pre>  <p>The size() function returns the number of elements in the current  multimap.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    (C++ Strings) <a href="../cppstring/capacity.html">capacity</a><br>    <a href="empty.html">empty</a><br>    (C++ Strings) <a href="../cppstring/length.html">length</a><br>    <a href="max_size.html">max_size</a><br>    (C++ Strings) <a href="../cppstring/resize.html">resize</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    swap  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  void swap( container&amp; from );</pre>  <p>The swap() function exchanges the elements of the current multimap  with those of <em>from</em>. This function operates in <a href=  "../complexity.html">constant time</a>.</p>  <p>For example, the following code uses the swap() function to  exchange the values of two strings:</p>  <pre class="example-code">   string first( &quot;This comes first&quot; );   string second( &quot;And this is second&quot; );   first.swap( second );   cout &lt;&lt; first &lt;&lt; endl;   cout &lt;&lt; second &lt;&lt; endl;          </pre>  <p>The above code displays:</p>  <pre class="example-code">   And this is second   This comes first             </pre>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    (C++ Lists) <a href="../cpplist/splice.html">splice</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    upper_bound  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  iterator upper_bound( const <a href="../containers.html">key_type</a>&amp; key );</pre>  <p>The function upper_bound() returns an iterator to the first  element in the multimap with a key greater than <em>key</em>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="lower_bound.html">lower_bound</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr>  <div class="name-format">    value_comp  </div>  <div class="syntax-name-format">    Syntax:  </div>  <pre class="syntax-box">  #include &lt;map&gt;  value_compare value_comp() const;</pre>  <p>The value_comp() function returns the function that compares  values.</p>  <p>value_comp() runs in <a href="../complexity.html">constant  time</a>.</p>  <div class="related-name-format">    Related topics:  </div>  <div class="related-content">    <a href="key_comp.html">key_comp</a>  </div>  </div>  </td>    </tr>  </table></body></html><hr></body></html>

⌨️ 快捷键说明

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