📄 qdict.html
字号:
prime that's slightly larger than the expected number of entries).This makes the hash distribution better which will lead to fasterlookup.<p> If <em>caseSensitive</em> is TRUE (the default), keys which differ only incase are considered different.<h3 class=fn><a name="QDict-2"></a>QDict::QDict ( const <a href="qdict.html">QDict</a><type> & dict )</h3>Constructs a copy of <em>dict</em>.<p> Each item in <em>dict</em> is inserted into this dictionary. Only thepointers are copied (shallow copy).<h3 class=fn><a name="~QDict"></a>QDict::~QDict ()</h3><p> Removes all items from the dictionary and destroys it.If <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>() is TRUE each value is deleted.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>QDict::clear ()<tt> [virtual]</tt></h3><p> 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 operate on the dictionary are 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>QDict::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>QDict::find ( const <a href="qstring.html">QString</a> & key ) const</h3><p> Returns the item with key <em>key</em>, or null if the key does notexist in the dictionary.<p> If there are two or more items with equal keys, then the last itemthat was inserted will be found.<p> Equivalent to the [] operator.<p> <b>Warning:</b> Your application will crash if you call <a href="#find">find</a>() on an emptydictionary; you can check with <a href="#isEmpty">isEmpty</a>() or <a href="#count">count</a>(). We don'tperform this check for efficiency reasons. <p> <p>See also <a href="#operator[]">operator[]</a>().<h3 class=fn>void <a name="insert"></a>QDict::insert ( const <a href="qstring.html">QString</a> & key, const type * item )</h3><p> Inserts the key <em>key</em> with value <em>item</em> into the dictionary.<p> The key does not have to be unique. If multiple items are insertedwith the same key, only the last item will be visible.<p> Null items are not allowed.<p> <p>See also <a href="#replace">replace</a>().<p>Example: <a href="themes-example.html#x286">themes/themes.cpp</a>.<h3 class=fn>bool <a name="isEmpty"></a>QDict::isEmpty () const</h3>Returns TRUE if the dictionary is empty, i.e. <a href="#count">count</a>() == 0; otherwisereturns FALSE.<p> <p>See also <a href="#count">count</a>().<h3 class=fn><a href="qdict.html">QDict</a><type> & <a name="operator-eq"></a>QDict::operator= ( const <a href="qdict.html">QDict</a><type> & dict )</h3><p> Assigns <em>dict</em> to this dictionary and returns a reference to thisdictionary.<p> This dictionary is first cleared, then each item in <em>dict</em> is insertedinto this dictionary.Only the pointers are copied (shallow copy), unless <a href="qptrcollection.html#newItem">newItem</a>() has beenreimplemented().<h3 class=fn>type * <a name="operator[]"></a>QDict::operator[] ( const <a href="qstring.html">QString</a> & key ) const</h3><p> Returns the item with key <em>key</em>, or null if the key does notexist in the dictionary.<p> If there are two or more items with equal keys, then the last itemthat was inserted will be found.<p> Equivalent to the <a href="#find">find</a>() function.<p> <b>Warning:</b> Your application will crash if you call find() on an emptydictionary; you can check with <a href="#isEmpty">isEmpty</a>() or <a href="#count">count</a>(). We don'tperform this check for efficiency reasons. <p> <p>See also <a href="#find">find</a>().<h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="read"></a>QDict::read ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qptrcollection.html#Item">QPtrCollection::Item</a> & item )<tt> [virtual protected]</tt></h3>Reads a dictionary item from the stream <em>s</em> and returns areference to the stream.<p> The default implementation sets <em>item</em> to 0.<p> <p>See also <a href="#write">write</a>().<h3 class=fn>bool <a name="remove"></a>QDict::remove ( const <a href="qstring.html">QString</a> & key )</h3><p> Removes the item with <em>key</em> from the dictionary.Returns TRUE if successful, or FALSE if the key does not exist in thedictionary.<p> If there are two or more items with equal keys, then the last itemthat was inserted will be removed.<p> The removed item is deleted if <a href="qptrcollection.html#setAutoDelete">auto-deletion</a> is enabled.<p> All dictionary iterators that refer to the removed item will be set topoint to the next item in the dictionary traversing order.<p> <p>See also <a href="#take">take</a>(), <a href="#clear">clear</a>() and <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>().<h3 class=fn>void <a name="replace"></a>QDict::replace ( const <a href="qstring.html">QString</a> & key, const type * item )</h3><p> Replaces the value of the key, <em>key</em> with <em>item</em>.<p> If the item does not already exist, it will be inserted.<p> Null items are not allowed.<p> Equivalent to:<pre> QDict<char> dict; ... if ( dict.<a href="#find">find</a>( key ) ) dict.<a href="#remove">remove</a>( key ); dict.<a href="#insert">insert</a>( key, item ); </pre> <p> If there are two or more items with equal keys, then the last itemthat was inserted will be replaced.<p> <p>See also <a href="#insert">insert</a>().<h3 class=fn>void <a name="resize"></a>QDict::resize ( uint newsize )</h3>Changes the size of the hashtable the <em>newsize</em>.The contents of the dictionary are preserved,but all iterators on the dictionary become invalid.<h3 class=fn>void <a name="setAutoDelete"></a>QPtrCollection::setAutoDelete ( bool enable )</h3><p> Sets the collection to auto-delete its contents if <em>enable</em> is TRUEand to never delete them if <em>enable</em> is FALSE.<p> If auto-deleting is turned on, all the items in a collection aredeleted when the collection itself is deleted. This is convenient ifthe collection has the only pointer to the items.<p> The default setting is FALSE, for safety. If you turn it on, becareful about copying the collection - you might find yourself withtwo collections deleting the same items.<p> Note that the auto-delete setting may also affect other functions insubclasses. For example, a subclass that has a <a href="#remove">remove</a>() functionwill remove the item from its data structure, and if auto-delete isenabled, will also delete the item.<p> <p>See also <a href="qptrcollection.html#autoDelete">autoDelete</a>().<p>Examples: <a href="grapher-nsplugin-example.html#x2777">grapher/grapher.cpp</a>, <a href="scribble-example.html#x945">scribble/scribble.cpp</a> and <a href="bigtable-example.html#x1489">table/bigtable/main.cpp</a>.<h3 class=fn>uint <a name="size"></a>QDict::size () const</h3>Returns the size of the internal hash array (as specified in theconstructor).<p>See also <a href="#count">count</a>().<h3 class=fn>void <a name="statistics"></a>QDict::statistics () const</h3>Debugging-only function that prints out the dictionary distributionusing <a href="qapplication.html#qDebug">qDebug</a>().<h3 class=fn>type * <a name="take"></a>QDict::take ( const <a href="qstring.html">QString</a> & key )</h3><p> Takes the item with <em>key</em> out of the dictionary withoutdeleting it (even if <a href="qptrcollection.html#setAutoDelete">auto-deletion</a> is enabled).<p> If there are two or more items with equal keys, then the last itemthat was inserted will be taken.<p> Returns a pointer to the item taken out, or null if the key does notexist in the dictionary.<p> All dictionary iterators that refer to the taken item will be set topoint to the next item in the dictionary traversal order.<p> <p>See also <a href="#remove">remove</a>(), <a href="#clear">clear</a>() and <a href="qptrcollection.html#setAutoDelete">setAutoDelete</a>().<h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="write"></a>QDict::write ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qptrcollection.html#Item">QPtrCollection::Item</a> ) const<tt> [virtual protected]</tt></h3>Writes a dictionary item to the stream <em>s</em> and returns areference to the stream.<p> <p>See also <a href="#read">read</a>().<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright © 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 © 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -