Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8e6051afcdb111a0317a58fb64c2abf5 > files > 3463

qt4-doc-4.6.3-0.2mdv2010.2.i586.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- q3ptrdict.qdoc -->
<head>
  <title>Qt 4.6: Q3PtrDict Class Reference</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<a name="//apple_ref/cpp/cl//Q3PtrDict"></a>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://qt.nokia.com/"><img src="images/qt-logo.png" align="left" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">All&nbsp;Functions</font></a>&nbsp;&middot; <a href="overviews.html"><font color="#004faf">Overviews</font></a></td></tr></table><h1 class="title">Q3PtrDict Class Reference<br /><span class="small-subtitle">[<a href="qt3support.html">Qt3Support</a> module]</span>
</h1>
<p>The Q3PtrDict class is a template class that provides a dictionary based on void* keys. <a href="#details">More...</a></p>
<pre> #include &lt;Q3PtrDict&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html">Porting to Qt 4</a> for more information.</p>
<p>Inherits <a href="q3ptrcollection.html">Q3PtrCollection</a>.</p>
<ul>
<li><a href="q3ptrdict-members.html">List of all members, including inherited members</a></li>
</ul>
<hr />
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#Q3PtrDict">Q3PtrDict</a></b> ( int <i>size</i> = 17 )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#Q3PtrDict-2">Q3PtrDict</a></b> ( const Q3PtrDict&lt;type&gt; &amp; <i>dict</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"></td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#dtor.Q3PtrDict">~Q3PtrDict</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">type * </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#find">find</a></b> ( void * <i>key</i> ) const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#insert">insert</a></b> ( void * <i>key</i>, const type * <i>item</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#isEmpty">isEmpty</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#remove">remove</a></b> ( void * <i>key</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#replace">replace</a></b> ( void * <i>key</i>, const type * <i>item</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#resize">resize</a></b> ( uint <i>newsize</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">uint </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#size">size</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#statistics">statistics</a></b> () const</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">type * </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#take">take</a></b> ( void * <i>key</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">Q3PtrDict&lt;type&gt; &amp; </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#operator-eq">operator=</a></b> ( const Q3PtrDict&lt;type&gt; &amp; <i>dict</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">type * </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#operator-5b-5d">operator[]</a></b> ( void * <i>key</i> ) const</td></tr>
</table>
<hr />
<a name="reimplemented-public-functions"></a>
<h2>Reimplemented Public Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#clear">clear</a></b> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual uint </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#count">count</a></b> () const</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>4 public functions inherited from <a href="q3ptrcollection.html#public-functions">Q3PtrCollection</a></li>
</ul>
<hr />
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr><td class="memItemLeft" align="right" valign="top">virtual QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#read">read</a></b> ( QDataStream &amp; <i>s</i>, Q3PtrCollection::Item &amp; <i>item</i> )</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">virtual QDataStream &amp; </td><td class="memItemRight" valign="bottom"><b><a href="q3ptrdict.html#write">write</a></b> ( QDataStream &amp; <i>s</i>, Q3PtrCollection::Item <i>item</i> ) const</td></tr>
</table>
<ul>
<li><div bar="2" class="fn"></div>2 protected functions inherited from <a href="q3ptrcollection.html#protected-functions">Q3PtrCollection</a></li>
</ul>
<a name="details"></a>
<hr />
<h2>Detailed Description</h2>
<p>The Q3PtrDict class is a template class that provides a dictionary based on void* keys.</p>
<p>Q3PtrDict is implemented as a template class. Define a template instance Q3PtrDict&lt;X&gt; to create a dictionary that operates on pointers to X (X*).</p>
<p>A dictionary is a collection of key-value pairs. The key is a void* used for insertion, removal and lookup. The value is a pointer. Dictionaries provide very fast insertion and lookup.</p>
<p>Example:</p>
<pre> Q3PtrDict&lt;char&gt; fields; // void* keys, char* values

 QLineEdit *le1 = new QLineEdit( this );
 le1-&gt;setText( &quot;Simpson&quot; );
 QLineEdit *le2 = new QLineEdit( this );
 le2-&gt;setText( &quot;Homer&quot; );
 QLineEdit *le3 = new QLineEdit( this );
 le3-&gt;setText( &quot;45&quot; );

 fields.insert( le1, &quot;Surname&quot; );
 fields.insert( le2, &quot;Forename&quot; );
 fields.insert( le3, &quot;Age&quot; );

 Q3PtrDictIterator&lt;char&gt; it( fields );
 for( ; it.current(); ++it )
     cout &lt;&lt; it.current() &lt;&lt; endl;
 cout &lt;&lt; endl;

 if ( fields[le1] ) // Prints &quot;Surname: Simpson&quot;
     cout &lt;&lt; fields[le1] &lt;&lt; &quot;: &quot; &lt;&lt; le1-&gt;text() &lt;&lt; endl;
 if ( fields[le2] ) // Prints &quot;Forename: Homer&quot;
     cout &lt;&lt; fields[le2] &lt;&lt; &quot;: &quot; &lt;&lt; le2-&gt;text() &lt;&lt; endl;

 fields.remove( le1 ); // Removes le1 from the dictionary
 cout &lt;&lt; le1-&gt;text() &lt;&lt; endl; // Prints &quot;Simpson&quot;</pre>
<p>In this example we use a dictionary to add an extra property (a char*) to the line edits we're using.</p>
<p>See <a href="q3dict.html">Q3Dict</a> for full details, including the choice of dictionary size, and how deletions are handled.</p>
<p>See also <a href="q3ptrdictiterator.html">Q3PtrDictIterator</a>, <a href="q3dict.html">Q3Dict</a>, <a href="q3asciidict.html">Q3AsciiDict</a>, and <a href="q3intdict.html">Q3IntDict</a>.</p>
<hr />
<h2>Member Function Documentation</h2>
<a name="//apple_ref/cpp/instm/Q3PtrDict/Q3PtrDict"></a>
<h3 class="fn"><a name="Q3PtrDict"></a>Q3PtrDict::Q3PtrDict ( int <i>size</i> = 17 )</h3>
<p>Constructs a dictionary using an internal hash array with the size <i>size</i>.</p>
<p>Setting <i>size</i> to a suitably large prime number (equal to or greater than the expected number of entries) makes the hash distribution better and improves lookup performance.</p>
<h3 class="fn"><a name="Q3PtrDict-2"></a>Q3PtrDict::Q3PtrDict ( const Q3PtrDict&lt;type&gt; &amp; <i>dict</i> )</h3>
<p>Constructs a copy of <i>dict</i>.</p>
<p>Each item in <i>dict</i> is inserted into this dictionary. Only the pointers are copied (shallow copy).</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/~Q3PtrDict"></a>
<h3 class="fn"><a name="dtor.Q3PtrDict"></a>Q3PtrDict::~Q3PtrDict ()</h3>
<p>Removes all items from the dictionary and destroys it.</p>
<p>All iterators that access this dictionary will be reset.</p>
<p>See also <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/clear"></a>
<h3 class="fn"><a name="clear"></a>void Q3PtrDict::clear ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="q3ptrcollection.html#clear">Q3PtrCollection::clear</a>().</p>
<p>Removes all items from the dictionary.</p>
<p>The removed items are deleted if <a href="q3ptrcollection.html#setAutoDelete">auto-deletion</a> is enabled.</p>
<p>All dictionary iterators that access this dictionary will be reset.</p>
<p>See also <a href="q3ptrdict.html#remove">remove</a>(), <a href="q3ptrdict.html#take">take</a>(), and <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/count"></a>
<h3 class="fn"><a name="count"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3PtrDict::count () const&nbsp;&nbsp;<tt> [virtual]</tt></h3>
<p>Reimplemented from <a href="q3ptrcollection.html#count">Q3PtrCollection::count</a>().</p>
<p>Returns the number of items in the dictionary.</p>
<p>See also <a href="q3ptrdict.html#isEmpty">isEmpty</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/find"></a>
<h3 class="fn"><a name="find"></a>type * Q3PtrDict::find ( void * <i>key</i> ) const</h3>
<p>Returns the item associated with <i>key</i>, or 0 if the key does not exist in the dictionary.</p>
<p>If there are two or more items with equal keys, then the most recently inserted item will be found.</p>
<p>Equivalent to operator[].</p>
<p>See also <a href="q3ptrdict.html#operator-5b-5d">operator[]</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/insert"></a>
<h3 class="fn"><a name="insert"></a>void Q3PtrDict::insert ( void * <i>key</i>, const type * <i>item</i> )</h3>
<p>Inserts the <i>key</i> with the <i>item</i> into the dictionary.</p>
<p>Multiple items can have the same key, in which case only the last item will be accessible using <a href="q3ptrdict.html#operator-5b-5d">operator[]</a>().</p>
<p><i>item</i> may not be 0.</p>
<p>See also <a href="q3ptrdict.html#replace">replace</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/isEmpty"></a>
<h3 class="fn"><a name="isEmpty"></a>bool Q3PtrDict::isEmpty () const</h3>
<p>Returns TRUE if the dictionary is empty; otherwise returns FALSE.</p>
<p>See also <a href="q3ptrdict.html#count">count</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/read"></a>
<h3 class="fn"><a name="read"></a><a href="qdatastream.html">QDataStream</a> &amp; Q3PtrDict::read ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, <a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a> &amp; <i>item</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Reads a dictionary item from the stream <i>s</i> and returns a reference to the stream.</p>
<p>The default implementation sets <i>item</i> to 0.</p>
<p>See also <a href="q3ptrdict.html#write">write</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/remove"></a>
<h3 class="fn"><a name="remove"></a>bool Q3PtrDict::remove ( void * <i>key</i> )</h3>
<p>Removes the item associated with <i>key</i> from the dictionary. Returns TRUE if successful, i.e&#x2e; if <i>key</i> is in the dictionary; otherwise returns FALSE.</p>
<p>If there are two or more items with equal keys, then the most recently inserted item will be removed.</p>
<p>The removed item is deleted if <a href="q3ptrcollection.html#setAutoDelete">auto-deletion</a> is enabled.</p>
<p>All dictionary iterators that refer to the removed item will be set to point to the next item in the dictionary traversal order.</p>
<p>See also <a href="q3ptrdict.html#take">take</a>(), <a href="q3ptrdict.html#clear">clear</a>(), and <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/replace"></a>
<h3 class="fn"><a name="replace"></a>void Q3PtrDict::replace ( void * <i>key</i>, const type * <i>item</i> )</h3>
<p>If the dictionary has key <i>key</i>, this key's item is replaced with <i>item</i>. If the dictionary doesn't contain key <i>key</i>, <i>item</i> is inserted into the dictionary using key <i>key</i>.</p>
<p><i>item</i> may not be 0.</p>
<p>Equivalent to</p>
<pre> Q3PtrDict&lt;ItemType&gt; dict;
     ...
 if ( dict.find( key ) )
     dict.remove( key );
 dict.insert( key, item );</pre>
<p>If there are two or more items with equal keys, then the most recently inserted item will be replaced.</p>
<p>See also <a href="q3ptrdict.html#insert">insert</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/resize"></a>
<h3 class="fn"><a name="resize"></a>void Q3PtrDict::resize ( <a href="qtglobal.html#uint-typedef">uint</a> <i>newsize</i> )</h3>
<p>Changes the size of the hash table to <i>newsize</i>. The contents of the dictionary are preserved, but all iterators on the dictionary become invalid.</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/size"></a>
<h3 class="fn"><a name="size"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3PtrDict::size () const</h3>
<p>Returns the size of the internal hash table (as specified in the constructor).</p>
<p>See also <a href="q3ptrdict.html#count">count</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/statistics"></a>
<h3 class="fn"><a name="statistics"></a>void Q3PtrDict::statistics () const</h3>
<p>Debugging-only function that prints out the dictionary distribution using <a href="qtglobal.html#qDebug">qDebug</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/take"></a>
<h3 class="fn"><a name="take"></a>type * Q3PtrDict::take ( void * <i>key</i> )</h3>
<p>Takes the item associated with <i>key</i> out of the dictionary without deleting it (even if <a href="q3ptrcollection.html#setAutoDelete">auto-deletion</a> is enabled).</p>
<p>If there are two or more items with equal keys, then the most recently inserted item will be removed.</p>
<p>Returns a pointer to the item taken out, or 0 if the key does not exist in the dictionary.</p>
<p>All dictionary iterators that refer to the taken item will be set to point to the next item in the dictionary traversal order.</p>
<p>See also <a href="q3ptrdict.html#remove">remove</a>(), <a href="q3ptrdict.html#clear">clear</a>(), and <a href="q3ptrcollection.html#setAutoDelete">setAutoDelete</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/write"></a>
<h3 class="fn"><a name="write"></a><a href="qdatastream.html">QDataStream</a> &amp; Q3PtrDict::write ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, <a href="q3ptrcollection.html#Item-typedef">Q3PtrCollection::Item</a> <i>item</i> ) const&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
<p>Writes a dictionary <i>item</i> to the stream <i>s</i> and returns a reference to the stream.</p>
<p>See also <a href="q3ptrdict.html#read">read</a>().</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/operator="></a>
<h3 class="fn"><a name="operator-eq"></a>Q3PtrDict&lt;type&gt; &amp; Q3PtrDict::operator= ( const Q3PtrDict&lt;type&gt; &amp; <i>dict</i> )</h3>
<p>Assigns <i>dict</i> to this dictionary and returns a reference to this dictionary.</p>
<p>This dictionary is first cleared and then each item in <i>dict</i> is inserted into the dictionary. Only the pointers are copied (shallow copy), unless <a href="q3ptrcollection.html#newItem">newItem</a>() has been reimplemented.</p>
<a name="//apple_ref/cpp/instm/Q3PtrDict/operator[]"></a>
<h3 class="fn"><a name="operator-5b-5d"></a>type * Q3PtrDict::operator[] ( void * <i>key</i> ) const</h3>
<p>Returns the item associated with <i>key</i>, or 0 if the key does not exist in the dictionary.</p>
<p>If there are two or more items with equal keys, then the most recently inserted item will be found.</p>
<p>Equivalent to the <a href="q3ptrdict.html#find">find</a>() function.</p>
<p>See also <a href="q3ptrdict.html#find">find</a>().</p>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="40%" align="left">Copyright &copy; 2010 Nokia Corporation and/or its subsidiary(-ies)</td>
<td width="20%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="40%" align="right"><div align="right">Qt 4.6.3</div></td>
</tr></table></div></address></body>
</html>