qmap.html

来自「QT 下载资料仅供参考」· HTML 代码 · 共 549 行 · 第 1/2 页

HTML
549 行
字号
Const reference to value_type.<h3 class=fn><a name="iterator"></a>QMap::iterator</h3> The map's iterator type.<h3 class=fn><a name="key_type"></a>QMap::key_type</h3> The map's key type. <h3 class=fn><a name="mapped_type"></a>QMap::mapped_type</h3> The map's data type. <h3 class=fn><a name="pointer"></a>QMap::pointer</h3> Pointer to value_type.<h3 class=fn><a name="reference"></a>QMap::reference</h3> Reference to value_type.<h3 class=fn><a name="size_type"></a>QMap::size_type</h3> An unsigned integral type, used to represent various sizes. <h3 class=fn><a name="value_type"></a>QMap::value_type</h3> Corresponds to <a href="qpair.html">QPair</a>&lt;key_type, mapped_type&gt;. <hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QMap"></a>QMap::QMap ()</h3>Constructs an empty map.<h3 class=fn><a name="QMap-2"></a>QMap::QMap ( const&nbsp;<a href="qmap.html">QMap</a>&lt;Key,&nbsp;T&gt;&nbsp;&amp;&nbsp;m )</h3>Constructs a copy of <em>m</em>.<p> This operation costs O(1) time because QMap is <a href="shclass.html#implicitly-shared">implicitly shared</a>.  Thefirst instance of applying modifications to a shared map will create acopy that takes in turn O(n) time. However, returning a QMap from afunction is very fast.<h3 class=fn><a name="QMap-3"></a>QMap::QMap ( const&nbsp;std::map&lt;Key,&nbsp;T&gt;&nbsp;&amp;&nbsp;m )</h3> Constructs a copy of <em>m</em>.<h3 class=fn><a name="~QMap"></a>QMap::~QMap ()</h3><p> Destroys the map. References to the values in the map and alliterators of this map become invalidated. Since QMap is highly tunedfor performance you won't see warnings if you use invalid iterators,because it is not possible for an iterator to check whether it isvalid or not.<h3 class=fn><a href="qmap.html#iterator">iterator</a> <a name="begin"></a>QMap::begin ()</h3><p> Returns an iterator pointing to the first element in the map. Thisiterator equals <a href="#end">end</a>() if the map is empty.<p> The items in the map are traversed in the order defined byoperator&lt;(Key, Key).<p> <p>See also <a href="#end">end</a>() and <a href="qmapiterator.html">QMapIterator</a>.<h3 class=fn><a href="qmap.html#const_iterator">const_iterator</a> <a name="begin-2"></a>QMap::begin () const</h3><p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <p>See also <a href="#end">end</a>() and <a href="qmapconstiterator.html">QMapConstIterator</a>.<h3 class=fn>void <a name="clear"></a>QMap::clear ()</h3>Removes all items from the map.<p> <p>See also <a href="#remove">remove</a>().<h3 class=fn>bool <a name="contains"></a>QMap::contains ( const&nbsp;Key&nbsp;&amp;&nbsp;k ) const</h3><p> Returns TRUE if the map contains an item with key <em>k</em>; otherwisereturns FALSE.<h3 class=fn><a href="qmap.html#size_type">size_type</a> <a name="count"></a>QMap::count ( const&nbsp;<a href="qmap.html#key_type">key_type</a>&nbsp;&amp;&nbsp;k ) const</h3> <p> Returns the number of items whose key is <em>k</em>. Since QMap doesnot allow duplicate keys, the return value is always 0 or 1.<p> This function is provided for STL compatibility.<h3 class=fn><a href="qmap.html#size_type">size_type</a> <a name="count-2"></a>QMap::count () const</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <p> Returns the number of items in the map.<p> <p>See also <a href="#isEmpty">isEmpty</a>().<h3 class=fn>void <a name="detach"></a>QMap::detach ()<tt> [protected]</tt></h3>If the map does not share its data with another QMap instance,nothing happens; otherwise the function creates a new copy of thismap and detaches from the shared one. This function is calledwhenever the map is modified.  The <a href="shclass.html#implicit-sharing">implicit sharing</a> mechanism isimplemented this way.<h3 class=fn>bool <a name="empty"></a>QMap::empty () const</h3> <p> Returns TRUE if the map contains zero items; otherwise returns FALSE.<p> This function is provided for STL compatibility. It is equivalentto <a href="#isEmpty">isEmpty</a>().<p> <p>See also <a href="#size">size</a>().<h3 class=fn><a href="qmap.html#iterator">iterator</a> <a name="end"></a>QMap::end ()</h3><p> The iterator returned by <a href="#end">end</a>() points to the element which is onepast the last element in the container. The past-the-end iteratoris still associated with the map it belongs to, however it is <em>not</em> dereferenceable; <a href="qwmatrix.html#operator*-5">operator*</a>() will not return a well-definedvalue. <p> This iterator equals <a href="#begin">begin</a>() if the map is empty.<p> <p>See also <a href="#begin">begin</a>() and <a href="qmapiterator.html">QMapIterator</a>.<h3 class=fn><a href="qmap.html#const_iterator">const_iterator</a> <a name="end-2"></a>QMap::end () const</h3><p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> The iterator returned by <a href="#end">end</a>() points to the element which is onepast the last element in the container. The past-the-end iteratoris still associated with the map it belongs to, however it is <em>not</em> dereferenceable; <a href="qwmatrix.html#operator*-5">operator*</a>() will not return a well-definedvalue. <p> This iterator equals <a href="#begin">begin</a>() if the map is empty.<p> <p>See also <a href="#begin">begin</a>() and <a href="qmapconstiterator.html">QMapConstIterator</a>.<h3 class=fn>void <a name="erase"></a>QMap::erase ( <a href="qmap.html#iterator">iterator</a>&nbsp;it )</h3> <p> Removes the item associated with the iterator <em>it</em> from the map.<p> This function is provided for STL compatibility. It is equivalentto <a href="#remove">remove</a>().<p> <p>See also <a href="#clear">clear</a>().<h3 class=fn>void <a name="erase-2"></a>QMap::erase ( const&nbsp;<a href="qmap.html#key_type">key_type</a>&nbsp;&amp;&nbsp;k )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <p> Removes the item with the key <em>k</em> from the map.<h3 class=fn><a href="qmap.html#iterator">iterator</a> <a name="find"></a>QMap::find ( const&nbsp;Key&nbsp;&amp;&nbsp;k )</h3><p> Returns an iterator pointing to the element with key <em>k</em> in the map.<p> Returns <a href="#end">end</a>() if no key matched.<p> <p>See also <a href="qmapiterator.html">QMapIterator</a>.<h3 class=fn><a href="qmap.html#const_iterator">const_iterator</a> <a name="find-2"></a>QMap::find ( const&nbsp;Key&nbsp;&amp;&nbsp;k ) const</h3><p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Returns an iterator pointing to the element with key <em>k</em> in the map.<p> Returns <a href="#end">end</a>() if no key matched.<p> <p>See also <a href="qmapconstiterator.html">QMapConstIterator</a>.<h3 class=fn><a href="qmap.html#iterator">iterator</a> <a name="insert"></a>QMap::insert ( const&nbsp;Key&nbsp;&amp;&nbsp;key, const&nbsp;T&nbsp;&amp;&nbsp;value, bool&nbsp;overwrite = TRUE )</h3><p> Inserts the <em>value</em> with <em>key</em>. If there is already a valueassociated with <em>key</em>, it is replaced, unless <em>overwrite</em> isFALSE (it is TRUE by default). <h3 class=fn><a href="qpair.html">QPair</a>&lt;iterator,&nbsp;bool&gt; <a name="insert-2"></a>QMap::insert ( const&nbsp;<a href="qmap.html#value_type">value_type</a>&nbsp;&amp;&nbsp;x )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <p> Inserts the (key, value) pair <em>x</em> into the map.  <em>x</em> is a <a href="qpair.html">QPair</a>whose <tt>first</tt> element is a key to be inserted and whose <tt>second</tt>element is the associated value to be inserted.  Returns a pairwhose <tt>first</tt> element is an iterator pointing to the inserted itemand whose <tt>second</tt> element is a bool indicating TRUE if <em>x</em> wasinserted and FALSE if it was not inserted because it was alreadypresent.<h3 class=fn>bool <a name="isEmpty"></a>QMap::isEmpty () const</h3><p> Returns TRUE if the map contains zero items; otherwise returns FALSE.<p> <p>See also <a href="#count">count</a>().<h3 class=fn><a href="qvaluelist.html">QValueList</a>&lt;Key&gt; <a name="keys"></a>QMap::keys () const</h3><p> Returns a list of all the keys in the map.<h3 class=fn><a href="qmap.html">QMap</a>&lt;Key,&nbsp;T&gt;&nbsp;&amp; <a name="operator-eq"></a>QMap::operator= ( const&nbsp;<a href="qmap.html">QMap</a>&lt;Key,&nbsp;T&gt;&nbsp;&amp;&nbsp;m )</h3>Assigns <em>m</em> to this map and returns a reference to this map.<p> All iterators of the current map become invalidated by thisoperation.  The cost of such an assignment is O(1), because QMap is<a href="shclass.html#implicitly-shared">implicitly shared</a>.<h3 class=fn><a href="qmap.html">QMap</a>&lt;Key,&nbsp;T&gt;&nbsp;&amp; <a name="operator-eq-2"></a>QMap::operator= ( const&nbsp;std::map&lt;Key,&nbsp;T&gt;&nbsp;&amp;&nbsp;m )</h3> <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> Assigns <em>m</em> to this map and returns a reference to this map.<p> All iterators of the current map become invalidated by thisoperation.<h3 class=fn>T &amp; <a name="operator[]"></a>QMap::operator[] ( const&nbsp;Key&nbsp;&amp;&nbsp;k )</h3>Returns the value associated with the key <em>k</em>. If no suchkey is present, an empty item is inserted with this keyand a reference to the item is returned.<p> You can use this operator both for reading and writing:<pre>    QMap&lt;QString, QString&gt; map;    map["Clinton"] = "Bill";    stream &lt;&lt; map["Clinton"];  </pre> <h3 class=fn>const T &amp; <a name="operator[]-2"></a>QMap::operator[] ( const&nbsp;Key&nbsp;&amp;&nbsp;k ) const</h3> <p> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <b>Warning:</b> This function differs from the non-const version of thesame function.  It will <em>not</em> insert an empty value if the key <em>k</em>does not exist.  This may lead to logic errors in your program.  Youshould check if the element exists before calling this function.<p> Returns the value associated with the key <em>k</em>. If no suchkey is present, a reference to an empty item is returned.<h3 class=fn>void <a name="remove"></a>QMap::remove ( <a href="qmap.html#iterator">iterator</a>&nbsp;it )</h3><p> Removes the item associated with the iterator <em>it</em> from the map.<p> <p>See also <a href="#clear">clear</a>().<h3 class=fn>void <a name="remove-2"></a>QMap::remove ( const&nbsp;Key&nbsp;&amp;&nbsp;k )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <p> Removes the item with the key <em>k</em> from the map.<h3 class=fn><a href="qmap.html#iterator">iterator</a> <a name="replace"></a>QMap::replace ( const&nbsp;Key&nbsp;&amp;&nbsp;k, const&nbsp;T&nbsp;&amp;&nbsp;v )</h3> <p> Replaces the value with key <em>k</em> from the map if possible, andinserts the new value <em>v</em> with key <em>k</em> in the map.<p> <p>See also <a href="#insert">insert</a>() and <a href="#remove">remove</a>().<h3 class=fn><a href="qmap.html#size_type">size_type</a> <a name="size"></a>QMap::size () const</h3> <p> Returns the number of items in the map.<p> This function is provided for STL compatibility. It is equivalentto <a href="#count">count</a>().<p> <p>See also <a href="#empty">empty</a>().<h3 class=fn><a href="qvaluelist.html">QValueList</a>&lt;T&gt; <a name="values"></a>QMap::values () const</h3><p> Returns a list of all the values in the map.<hr><h2>Related Functions</h2><h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-lt-lt"></a>operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, const&nbsp;<a href="qmap.html">QMap</a>&lt;Key,&nbsp;T&gt;&nbsp;&amp;&nbsp;m )</h3>Writes the map <em>m</em> to the stream <em>s</em>. The types <em>Key</em> and <em>T</em>must implement the streaming operator as well.<h3 class=fn><a href="qdatastream.html">QDataStream</a>&nbsp;&amp; <a name="operator-gt-gt"></a>operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a>&nbsp;&amp;&nbsp;s, <a href="qmap.html">QMap</a>&lt;Key,&nbsp;T&gt;&nbsp;&amp;&nbsp;m )</h3>Reads the map <em>m</em> from the stream <em>s</em>. The types <em>Key</em> and <em>T</em>must implement the streaming operator as well.<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright &copy; 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright &copy; 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>

⌨️ 快捷键说明

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