qintdict.html

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

HTML
322
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/doc/qintdict.doc:41 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QIntDict Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QIntDict Class Reference</h1><p>The QIntDict class is a template class that provides a dictionary based on long keys.<a href="#details">More...</a><p><tt>#include &lt;<a href="qintdict-h.html">qintdict.h</a>&gt;</tt><p>Inherits <a href="qptrcollection.html">QPtrCollection</a>.<p><a href="qintdict-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QIntDict"><b>QIntDict</b></a> ( int&nbsp;size = 17 )</div></li><li><div class=fn><a href="#QIntDict-2"><b>QIntDict</b></a> ( const&nbsp;QIntDict&lt;type&gt;&nbsp;&amp;&nbsp;dict )</div></li><li><div class=fn><a href="#~QIntDict"><b>~QIntDict</b></a> ()</div></li><li><div class=fn>QIntDict&lt;type&gt; &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QIntDict&lt;type&gt;&nbsp;&amp;&nbsp;dict )</div></li><li><div class=fn>virtual uint <a href="#count"><b>count</b></a> () const</div></li><li><div class=fn>uint <a href="#size"><b>size</b></a> () const</div></li><li><div class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</div></li><li><div class=fn>void <a href="#insert"><b>insert</b></a> ( long&nbsp;key, const&nbsp;type&nbsp;*&nbsp;item )</div></li><li><div class=fn>void <a href="#replace"><b>replace</b></a> ( long&nbsp;key, const&nbsp;type&nbsp;*&nbsp;item )</div></li><li><div class=fn>bool <a href="#remove"><b>remove</b></a> ( long&nbsp;key )</div></li><li><div class=fn>type * <a href="#take"><b>take</b></a> ( long&nbsp;key )</div></li><li><div class=fn>type * <a href="#find"><b>find</b></a> ( long&nbsp;key ) const</div></li><li><div class=fn>type * <a href="#operator[]"><b>operator[]</b></a> ( long&nbsp;key ) const</div></li><li><div class=fn>virtual void <a href="#clear"><b>clear</b></a> ()</div></li><li><div class=fn>void <a href="#resize"><b>resize</b></a> ( uint&nbsp;newsize )</div></li><li><div class=fn>void <a href="#statistics"><b>statistics</b></a> () const</div></li></ul><h2>Important Inherited Members</h2><ul><li><div class=fn>bool <a href="#autoDelete"><b>autoDelete</b></a> () const</div></li><li><div class=fn>void <a href="#setAutoDelete"><b>setAutoDelete</b></a> ( bool&nbsp;enable )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>virtual QDataStream &amp; <a href="#read"><b>read</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPtrCollection::Item&nbsp;&amp;&nbsp;item )</div></li><li><div class=fn>virtual QDataStream &amp; <a href="#write"><b>write</b></a> ( QDataStream&nbsp;&amp;&nbsp;s, QPtrCollection::Item ) const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QIntDict class is a template class that provides a dictionary based on long keys.<p> <p> <p> <a href="qmap.html">QMap</a> is an STL-compatible alternative to this class.<p> QIntDict is implemented as a template class. Define atemplate instance QIntDict&lt;X&gt; to create a dictionary that operates onpointers to X (X*).<p> A dictionary is a collection of key-value pairs. The key is an <tt>long</tt> used for insertion, removal and lookup. The value is a pointer.Dictionaries provide very fast insertion and lookup.<p> Example:<pre>    QIntDict&lt;QLineEdit&gt; fields;    for ( int i = 0; i &lt; 3; i++ )        fields.<a href="#insert">insert</a>( i, new <a href="qlineedit.html">QLineEdit</a>( this ) );    fields[0]-&gt;setText( "Homer" );    fields[1]-&gt;setText( "Simpson" );    fields[2]-&gt;setText( "45" );    <a href="qintdictiterator.html">QIntDictIterator</a>&lt;char&gt; it( fields ); // See QIntDictIterator    for ( ; it.<a href="qintdictiterator.html#current">current</a>(); ++it )        cout &lt;&lt; it.<a href="qintdictiterator.html#currentKey">currentKey</a>() &lt;&lt; ": " &lt;&lt; it.<a href="qintdictiterator.html#current">current</a>()-&gt;text() &lt;&lt; endl;        for ( int i = 0; i &lt; 3; i++ )        cout &lt;&lt; fields[i]-&gt;text() &lt;&lt; " "; // Prints "Homer Simpson 45"    cout &lt;&lt; endl;    fields.<a href="#remove">remove</a>( 1 ); // Does not delete the line edit    for ( int i = 0; i &lt; 3; i++ )        if ( fields[i] )            cout &lt;&lt; fields[i]-&gt;text() &lt;&lt; " "; // Prints "Homer 45"    </pre> <p> See <a href="qdict.html">QDict</a> for full details, including the choice of dictionarysize, and how deletions are handled. <p> <p>See also <a href="qintdictiterator.html">QIntDictIterator</a>, <a href="qdict.html">QDict</a>, <a href="qasciidict.html">QAsciiDict</a>, <a href="qptrdict.html">QPtrDict</a>, <a href="collection.html">Collection Classes</a>, <a href="collection.html">Collection Classes</a> and <a href="tools.html">Non-GUI Classes</a>.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QIntDict"></a>QIntDict::QIntDict ( int&nbsp;size = 17 )</h3>Constructs a dictionary using an internal hash array of size<em>size</em>.<p> Setting <em>size</em> to a suitably large prime number(equal to or greater than the expected number of entries) makes the hashdistribution better and hence the lookup faster.<h3 class=fn><a name="QIntDict-2"></a>QIntDict::QIntDict ( const&nbsp;<a href="qintdict.html">QIntDict</a>&lt;type&gt;&nbsp;&amp;&nbsp;dict )</h3>Constructs a copy of <em>dict</em>.<p> Each item in <em>dict</em> is inserted into this dictionary.Only the pointers are copied (shallow copy).<h3 class=fn><a name="~QIntDict"></a>QIntDict::~QIntDict ()</h3>Removes all items from the dictionary and destroys it.<p> All iterators that access this dictionary will be reset.<p> <p>See also <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>().<h3 class=fn>bool <a name="autoDelete"></a>QPtrCollection::autoDelete () const</h3><p> Returns the setting of the auto-delete option. The default is FALSE.<p> <p>See also <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>().<h3 class=fn>void <a name="clear"></a>QIntDict::clear ()<tt> [virtual]</tt></h3>Removes all items from the dictionary.<p> The removed items are deleted if <a href="qptrcollection.html#setAutoDelete">auto-deletion</a> is enabled.<p> All dictionary iterators that access this dictionary will be reset.<p> <p>See also <a href="#remove">remove</a>(), <a href="#take">take</a>() and <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>().<p>Reimplemented from <a href="qptrcollection.html#clear">QPtrCollection</a>.<h3 class=fn>uint <a name="count"></a>QIntDict::count () const<tt> [virtual]</tt></h3>Returns the number of items in the dictionary.<p>See also <a href="#isEmpty">isEmpty</a>().<p>Reimplemented from <a href="qptrcollection.html#count">QPtrCollection</a>.<h3 class=fn>type * <a name="find"></a>QIntDict::find ( long&nbsp;key ) const</h3>Returns the item associated with <em>key</em>, or null if the key does notexist in the dictionary.<p> This function uses an internal hashing algorithm to optimize lookup.<p> If there are two or more items with equal keys, then the last inserted

⌨️ 快捷键说明

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