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

📄 multimap.html

📁 VC书籍介绍C++的应用的TheOODesignProcess.zip 电子书好用的
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<HTML>
<HEAD>
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
   <META NAME="Author" CONTENT="Zafir Anjum">
   <TITLE>MFC Programmer's SourceBook : STL Programmer's Guide</TITLE>
    <META name="description" 
     content="A freely available implementation 
     of the C++ Standard Template Library, including 
     hypertext documentation.">
	<META name="keywords" 
	content="generic programming, STL, standard template library">
</HEAD>

<SCRIPT LANGUAGE="JavaScript"><!--
var adcategory = "cpp";
// -->
</SCRIPT>
<body background="../../fancyhome/back.gif" bgcolor="#FFFFFF" >
<SCRIPT LANGUAGE="JavaScript"><!--
var nfrm = location.href.indexOf("_nfrm_");
var validframes = (top.frames.length > 0 && top.frames['ad'] && top.frames['logo'] );
var random = Math.random();

if( !validframes && nfrm == -1 )
{
	var dclkPage = "www.codeguru.com/";
	if( self.adcategory )
		dclkPage += adcategory;
	else
		dclkPage += "mfc";
	document.write('<nolayer><center>');
	document.write('<iframe src="http://ad.doubleclick.net/adi/' + dclkPage + ';ord='
	 + random + '" width=470 height=62 marginwidth=0 marginheight=0 hspace=0 vspace=0 '
	 + 'frameborder=0 scrolling=no bordercolor="#000000">');
	document.write('<a href="http://ad.doubleclick.net/jump/' + dclkPage + ';ord='
	 + random + '">');
	document.write('<img src="http://ad.doubleclick.net/ad/' + dclkPage + ';ord='
	 + random + '" height=60 width=468>' + '</a>');
	document.write('</iframe>');
	document.write('</center></nolayer>');
	document.write('<layer  src="http://ad.doubleclick.net/adl/' + dclkPage + 
	 ';ord=' + random + '"></layer>');
	document.write('<ilayer visibility=hide width=468 height=83></ilayer>');
}


//		top.location = "/show.cgi?" + adcategory + "=" + location.pathname;


// -->
</SCRIPT>
<noscript>
<p align="center">
<a href="http://ad.doubleclick.net/jump/www.codeguru.com/cpp;ord=NupaS9FCY34AAHczWQI">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupaS9FCY34AAHczWQI"></a>
</p>
</noscript>





<BR Clear>
<H1>multimap&lt;Key, Data, Compare, Alloc&gt;</H1>

<Table CellPadding=0 CellSpacing=0 width=100%>
<TR>
<TD Align=left><Img src = "containers.gif" Alt=""   WIDTH = "194"  HEIGHT = "38" ></TD>
<TD Align=right><Img src = "type.gif" Alt=""   WIDTH = "194"  HEIGHT = "39" ></TD>
</TR>
<TR>
<TD Align=left VAlign=top><b>Category</b>: containers</TD>
<TD Align=right VAlign=top><b>Component type</b>: type</TD>
</TR>
</Table>

<h3>Description</h3>
<tt>Multimap</tt> is a <A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
that associates objects of type <tt>Key</tt> with
objects of type <tt>Data</tt>.  <tt>multimap</tt> is a 
<A href="PairAssociativeContainer.html">Pair Associative Container</A>, 
meaning that its value type is
<tt><A href="pair.html">pair</A>&lt;const Key, Data&gt;</tt>.  It is also a 
<A href="MultipleAssociativeContainer.html">Multiple Associative Container</A>,
meaning that there is no limit on the number of
elements with the same key.
<P>
<tt>Multimap</tt> has the important property that inserting a new element
into a <tt>multimap</tt> does not invalidate iterators that point to existing
elements.  Erasing an element from a set also does not invalidate
any iterators, except, of course, for iterators that actually point 
to the element that is being erased.
<h3>Example</h3>
<pre>
struct ltstr
{
  bool operator()(const char* s1, const char* s2) const
  {
    return strcmp(s1, s2) &lt; 0;
  }
};

int main()
{
  multimap&lt;const char*, int, ltstr&gt; m;
  
  m.insert(pair&lt;const char* const, int&gt;(&quot;a&quot;, 1));
  m.insert(pair&lt;const char* const, int&gt;(&quot;c&quot;, 2));
  m.insert(pair&lt;const char* const, int&gt;(&quot;b&quot;, 3));
  m.insert(pair&lt;const char* const, int&gt;(&quot;b&quot;, 4));
  m.insert(pair&lt;const char* const, int&gt;(&quot;a&quot;, 5));
  m.insert(pair&lt;const char* const, int&gt;(&quot;b&quot;, 6));

  cout &lt;&lt; &quot;Number of elements with key a: &quot; &lt;&lt; m.count(&quot;a&quot;) &lt;&lt; endl;
  cout &lt;&lt; &quot;Number of elements with key b: &quot; &lt;&lt; m.count(&quot;b&quot;) &lt;&lt; endl;
  cout &lt;&lt; &quot;Number of elements with key c: &quot; &lt;&lt; m.count(&quot;c&quot;) &lt;&lt; endl;

  cout &lt;&lt; &quot;Elements in m: &quot; &lt;&lt; endl;
  for (multimap&lt;const char*, int, ltstr&gt;::iterator it = m.begin();
       it != m.end();
       ++it)
   cout &lt;&lt; &quot;  [&quot; &lt;&lt; (*it).first &lt;&lt; &quot;, &quot; &lt;&lt; (*it).second &lt;&lt; &quot;]&quot; &lt;&lt; endl;
}
</pre>
<h3>Definition</h3>
<tt>Multimap</tt> is declared in <A href="multimap.h">multimap.h</A>.
The implementation is in <A href="multimap.h">multimap.h</A> and
<A href="tree.h">tree.h</A>.
<h3>Template parameters</h3>
<Table border>
<TR>
<TH>
Parameter
</TH>
<TH>
Description
</TH>
<TH>
Default
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>Key</tt>
</TD>
<TD VAlign=top>
The multimap's key type.  This is also defined as <tt>multimap::key_type</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>Data</tt>
</TD>
<TD VAlign=top>
The multimap's data type.  This is also defined as <tt>multimap::data_type</tt>.
</TD>
<TD VAlign=top>
&nbsp;
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>Compare</tt>
</TD>
<TD VAlign=top>
The key comparison function, a <A href="StrictWeakOrdering.html">Strict Weak Ordering</A> whose
   argument type is <tt>key_type</tt>; it returns <tt>true</tt> if its first 
   argument is less than its second argument, and <tt>false</tt> otherwise.
   This is also defined as <tt>multimap::key_compare</tt>.
</TD>
<TD VAlign=top>
<tt><A href="less.html">less</A>&lt;Key&gt;</tt>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>Alloc</tt>
</TD>
<TD VAlign=top>
The <tt>multimap</tt>'s allocator, used for all internal memory management.
</TD>
<TD VAlign=top>
<tt><A href="Allocators.html">alloc</A></tt>
</TD>
</tr>
</table>
<h3>Model of</h3>
<A href="MultipleSortedAssociativeContainer.html">Multiple Sorted Associative Container</A>,
<A href="PairAssociativeContainer.html">Pair Associative Container</A>
<h3>Type requirements</h3>
<UL>
<LI>
<tt>Data</tt> is <A href="Assignable.html">Assignable</A>.
<LI>
<tt>Compare</tt> is a <A href="StrictWeakOrdering.html">Strict Weak Ordering</A> whose argument type
   is <tt>Key</tt>.
<LI>
<tt>Alloc</tt> is an <A href="Allocators.html">Allocator</A>.
</UL>
<h3>Public base classes</h3>
None.
<h3>Members</h3>
<Table border>
<TR>
<TH>
Member
</TH>
<TH>
Where defined
</TH>
<TH>
Description
</TH>
</TR>
<TR>
<TD VAlign=top>
<tt>key_type</tt>
</TD>
<TD VAlign=top>
 <A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
The <tt>multimap</tt>'s key type, <tt>Key</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>data_type</tt>
</TD>
<TD VAlign=top>
 <A href="PairAssociativeContainer.html">Pair Associative Container</A>
</TD>
<TD VAlign=top>
The type of object associated with the keys.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>value_type</tt>
</TD>
<TD VAlign=top>
 <A href="PairAssociativeContainer.html">Pair Associative Container</A>
</TD>
<TD VAlign=top>
The type of object, <tt>pair&lt;const key_type, data_type&gt;</tt>, stored in the multimap.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>key_compare</tt>
</TD>
<TD VAlign=top>
 <A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
 <A href="functors.html">Function object</A> that compares two keys for ordering.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>value_compare</tt>
</TD>
<TD VAlign=top>
 <A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
 <A href="functors.html">Function object</A> that compares two values for ordering.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>pointer</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Pointer to <tt>T</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reference</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Reference to <tt>T</tt>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_reference</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Const reference to <tt>T</tt>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>size_type</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
An unsigned integral type.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>difference_type</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
A signed integral type.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>iterator</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Iterator used to iterate through a <tt>multimap</tt>. <A href="#1">[1]</A>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_iterator</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Const iterator used to iterate through a <tt>multimap</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_iterator</tt>
</TD>
<TD VAlign=top>
 <A href="ReversibleContainer.html">Reversible Container</A>
</TD>
<TD VAlign=top>
Iterator used to iterate backwards through a <tt>multimap</tt>. <A href="#1">[1]</A>
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_reverse_iterator</tt>
</TD>
<TD VAlign=top>
 <A href="ReversibleContainer.html">Reversible Container</A>
</TD>
<TD VAlign=top>
Const iterator used to iterate backwards through a <tt>multimap</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>iterator begin()</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Returns an <tt>iterator</tt> pointing to the beginning of the <tt>multimap</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>iterator end()</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Returns an <tt>iterator</tt> pointing to the end of the <tt>multimap</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_iterator begin() const</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Returns a <tt>const_iterator</tt> pointing to the beginning of the <tt>multimap</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_iterator end() const</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Returns a <tt>const_iterator</tt> pointing to the end of the <tt>multimap</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_iterator rbegin()</tt>
</TD>
<TD VAlign=top>
 <A href="ReversibleContainer.html">Reversible Container</A>
</TD>
<TD VAlign=top>
Returns a <tt>reverse_iterator</tt> pointing to the beginning of the
   reversed multimap.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>reverse_iterator rend()</tt>
</TD>
<TD VAlign=top>
 <A href="ReversibleContainer.html">Reversible Container</A>
</TD>
<TD VAlign=top>
Returns a <tt>reverse_iterator</tt> pointing to the end of the
   reversed multimap.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_reverse_iterator rbegin() const</tt>
</TD>
<TD VAlign=top>
 <A href="ReversibleContainer.html">Reversible Container</A>
</TD>
<TD VAlign=top>
Returns a <tt>const_reverse_iterator</tt> pointing to the beginning of the
   reversed multimap.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_reverse_iterator rend() const</tt>
</TD>
<TD VAlign=top>
 <A href="ReversibleContainer.html">Reversible Container</A>
</TD>
<TD VAlign=top>
Returns a <tt>const_reverse_iterator</tt> pointing to the end of the
   reversed multimap.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>size_type size() const</tt>
</TD>
<TD VAlign=top>
 <A href="Container.html">Container</A>

⌨️ 快捷键说明

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