📄 map.html
字号:
<TD VAlign=top>
<A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
<tt>true</tt> if the <tt>map</tt>'s size is <tt>0</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>key_compare key_comp() const</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Returns the <tt>key_compare</tt> object used by the <tt>map</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>value_compare value_comp() const</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Returns the <tt>value_compare</tt> object used by the <tt>map</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>map()</tt>
</TD>
<TD VAlign=top>
<A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Creates an empty <tt>map</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>map(const key_compare& comp)</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Creates an empty <tt>map</tt>, using <tt>comp</tt> as the <tt>key_compare</tt> object.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template <class <A href="InputIterator.html">InputIterator</A>>
map(InputIterator f, InputIterator l)
<A href="#2">[2]</A>
</pre>
</TD>
<TD VAlign=top>
<A href="UniqueSortedAssociativeContainer.html">Unique Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Creates a map with a copy of a range.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template <class <A href="InputIterator.html">InputIterator</A>>
map(InputIterator f, InputIterator l,
const key_compare& comp)
<A href="#2">[2]</A>
</pre>
</TD>
<TD VAlign=top>
<A href="UniqueSortedAssociativeContainer.html">Unique Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Creates a map with a copy of a range, using <tt>comp</tt> as the <tt>key_compare</tt>
object.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>map(const map&)</tt>
</TD>
<TD VAlign=top>
<A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
The copy constructor.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>map& operator=(const map&)</tt>
</TD>
<TD VAlign=top>
<A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
The assignment operator
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>void swap(map&)</tt>
</TD>
<TD VAlign=top>
<A href="Container.html">Container</A>
</TD>
<TD VAlign=top>
Swaps the contents of two maps.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
pair<iterator, bool>
insert(const value_type& x)
</pre>
</TD>
<TD VAlign=top>
<A href="UniqueAssociativeContainer.html">Unique Associative Container</A>
</TD>
<TD VAlign=top>
Inserts <tt>x</tt> into the <tt>map</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
iterator insert(iterator pos,
const value_type& x)
</pre>
</TD>
<TD VAlign=top>
<A href="UniqueSortedAssociativeContainer.html">Unique Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Inserts <tt>x</tt> into the <tt>map</tt>, using <tt>pos</tt> as a hint to where it will be
inserted.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
template <class <A href="InputIterator.html">InputIterator</A>>
void insert(InputIterator, InputIterator)
<A href="#2">[2]</A>
</pre>
</TD>
<TD VAlign=top>
<A href="UniqueSortedAssociativeContainer.html">Unique Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Inserts a range into the <tt>map</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>void erase(iterator pos)</tt>
</TD>
<TD VAlign=top>
<A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
Erases the element pointed to by <tt>pos</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>size_type erase(const key_type& k)</tt>
</TD>
<TD VAlign=top>
<A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
Erases the element whose key is <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>void erase(iterator first, iterator last)</tt>
</TD>
<TD VAlign=top>
<A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
Erases all elements in a range.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>void clear()</tt>
</TD>
<TD VAlign=top>
<A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
Erases all of the elements.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>iterator find(const key_type& k)</tt>
</TD>
<TD VAlign=top>
<A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
Finds an element whose key is <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_iterator find(const key_type& k) const</tt>
</TD>
<TD VAlign=top>
<A href="AssociativeContainer.html">Associative Container</A>
</TD>
<TD VAlign=top>
Finds an element whose key is <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>size_type count(const key_type& k)</tt>
</TD>
<TD VAlign=top>
<A href="UniqueAssociativeContainer.html">Unique Associative Container</A>
</TD>
<TD VAlign=top>
Counts the number of elements whose key is <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>iterator lower_bound(const key_type& k)</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Finds the first element whose key is not less than <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_iterator lower_bound(const key_type& k) const</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Finds the first element whose key is not less than <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>iterator upper_bound(const key_type& k)</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Finds the first element whose key greater than <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<tt>const_iterator upper_bound(const key_type& k) const</tt>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Finds the first element whose key greater than <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
pair<iterator, iterator>
equal_range(const key_type& k)
</pre>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Finds a range containing all elements whose key is <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
pair<const_iterator, const_iterator>
equal_range(const key_type& k) const
</pre>
</TD>
<TD VAlign=top>
<A href="SortedAssociativeContainer.html">Sorted Associative Container</A>
</TD>
<TD VAlign=top>
Finds a range containing all elements whose key is <tt>k</tt>.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
data_type&
operator[](const key_type& k) <A href="#3">[3]</A>
</pre>
</TD>
<TD VAlign=top>
<tt>map</tt>
</TD>
<TD VAlign=top>
See below.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
bool operator==(const map&,
const map&)
</pre>
</TD>
<TD VAlign=top>
<A href="ForwardContainer.html">Forward Container</A>
</TD>
<TD VAlign=top>
Tests two maps for equality. This is a global function, not
a member function.
</TD>
</TR>
<TR>
<TD VAlign=top>
<pre>
bool operator<(const map&,
const map&)
</pre>
</TD>
<TD VAlign=top>
<A href="ForwardContainer.html">Forward Container</A>
</TD>
<TD VAlign=top>
Lexicographical comparison. This is a global function, not
a member function.
</TD>
</tr>
</table>
<h3>New members</h3>
These members are not defined in the
<A href="UniqueSortedAssociativeContainer.html">Unique Sorted Associative Container</A> and <A href="PairAssociativeContainer.html" tppabs="http://www.sgi.com/Technology/STL/PairAssociativeContainer.shtml">Pair Associative Container</A>
requirements, but are unique to <tt>map</tt>:
<Table border>
<TR>
<TH>
Member function
</TH>
<TH>
Description
</TH>
</TR>
<TR>
<TD VAlign=top>
<pre>
data_type&
operator[](const key_type& k) <A href="#3">[3]</A>
</pre>
</TD>
<TD VAlign=top>
Returns a reference to the object that is associated with
a particular key. If the <tt>map</tt> does not already contain such
an object, <tt>operator[]</tt> inserts the default object <tt>data_type()</tt>. <A href="#3">[3]</A>
</TD>
</tr>
</table>
<h3>Notes</h3>
<P><A name="1">[1]</A>
<tt>Map::iterator</tt> is not a mutable iterator, because
<tt>map::value_type</tt> is not <A href="Assignable.html">Assignable</A>. That is, if <tt>i</tt> is of
type <tt>map::iterator</tt> and <tt>p</tt> is of type
<tt>map::value_type</tt>, then <tt>*i = p</tt> is not a valid
expression. However, <tt>map::iterator</tt> isn't a constant iterator
either, because it can be used to modify the object that it points to.
Using the same notation as above, <tt>(*i).second = p</tt> is a valid
expression. The same point applies to <tt>map::reverse_iterator</tt>.
<P><A name="2">[2]</A>
This member function relies on <i>member template</i> functions, which
at present (early 1998) are not supported by all compilers. If your
compiler supports member templates, you can call this function with
any type of <A href="InputIterator.html">input iterator</A>. If your
compiler does not yet support member templates, though, then the
arguments must either be of type <tt>const value_type*</tt> or of type
<tt>map::const_iterator</tt>.
<P><A name="3">[3]</A>
Since <tt>operator[]</tt> might insert a new element into the <tt>map</tt>,
it can't possibly be a <tt>const</tt> member function. Note that the
definition of <tt>operator[]</tt> is extremely simple: <tt>m[k]</tt> is equivalent
to <tt>(*((m.insert(value_type(k, data_type()))).first)).second</tt>.
Strictly speaking, this member function is unnecessary: it exists
only for convenience.
<h3>See also</h3>
<A href="AssociativeContainer.html">Associative Container</A>, <A href="SortedAssociativeContainer.html" tppabs="http://www.sgi.com/Technology/STL/SortedAssociativeContainer.shtml">Sorted Associative Container</A>,
<A href="PairAssociativeContainer.html">Pair Associative Container</A>, <A href="UniqueSortedAssociativeContainer.html" tppabs="http://www.sgi.com/Technology/STL/UniqueSortedAssociativeContainer.shtml">Unique Sorted Associative Container</A>,
<tt><A href="set.html">set</A></tt>
<tt><A href="multiset.html">multiset</A></tt>, <tt><A href="Multimap.html" tppabs="http://www.sgi.com/Technology/STL/Multimap.shtml">multimap</A></tt>,
<tt><A href="hash_set.html">hash_set</A></tt>, <tt><A href="hash_map.html" tppabs="http://www.sgi.com/Technology/STL/hash_map.shtml">hash_map</A></tt>,
<tt><A href="hash_multiset.html">hash_multiset</A></tt>, <tt><A href="hash_multimap.html" tppabs="http://www.sgi.com/Technology/STL/hash_multimap.shtml">hash_multimap</A></tt>,
<HR SIZE="6"> <FONT SIZE="-2"> Copyright © 1996 Silicon Graphics, Inc.
<HR>
<TABLE BORDER=0 WIDTH="100%" >
<TR>
<TD WIDTH="33%"><FONT SIZE=-1><A HREF="index.html" >
STL</A></FONT></TD>
<TD WIDTH="33%">
<CENTER><FONT SIZE=-2>© Copyright 1997-1998 CodeGuru</FONT> </CENTER>
</TD>
<TD WIDTH="34%">
<DIV ALIGN=right><FONT SIZE=-1>Contact : <A HREF="mailto:webmaster@codeguru.com">webmaster@codeguru.com</A> </FONT></DIV>
</TD>
</TR>
</TABLE>
<SCRIPT LANGUAGE="JavaScript" ><!--
var adurl = "/cgi-bin/doubleclick.cgi?";
if( self.adcategory )
adurl += adcategory;
else
adurl += "mfc";
if( self.parent.norefreshad )
parent.norefreshad = false;
else if( validframes )
parent.frames['ad'].location = adurl;
if( !validframes && nfrm == -1)
{
var dclkPage = "www.codeguru.com/";
if( self.adcategory )
dclkPage += adcategory;
else
dclkPage += "mfc";
// var random = Math.random();
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>');
}
// -->
</SCRIPT>
<!-- SCRIPT LANGUAGE="JavaScript" SRC="/global/fscript.js">
//
</SCRIPT -->
<noscript>
<p align="center">
<a href="http://ad.doubleclick.net/jump/www.codeguru.com/cpp;ord=NupaQNFCY34AAHd@Ic0">
<img src="http://ad.doubleclick.net/ad/www.codeguru.com/cpp;ord=NupaQNFCY34AAHd@Ic0"></a>
</p>
</noscript>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -