qasciidict.html
来自「QT 下载资料仅供参考」· HTML 代码 · 共 329 行 · 第 1/2 页
HTML
329 行
<!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/qasciidict.doc:41 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QAsciiDict 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 Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped 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>QAsciiDict Class Reference</h1><p>The QAsciiDict class is a template class that provides a dictionary based on char* keys.<a href="#details">More...</a><p><tt>#include <<a href="qasciidict-h.html">qasciidict.h</a>></tt><p>Inherits <a href="qptrcollection.html">QPtrCollection</a>.<p><a href="qasciidict-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QAsciiDict"><b>QAsciiDict</b></a> ( int size = 17, bool caseSensitive = TRUE, bool copyKeys = TRUE )</div></li><li><div class=fn><a href="#QAsciiDict-2"><b>QAsciiDict</b></a> ( const QAsciiDict<type> & dict )</div></li><li><div class=fn><a href="#~QAsciiDict"><b>~QAsciiDict</b></a> ()</div></li><li><div class=fn>QAsciiDict<type> & <a href="#operator-eq"><b>operator=</b></a> ( const QAsciiDict<type> & 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> ( const char * key, const type * item )</div></li><li><div class=fn>void <a href="#replace"><b>replace</b></a> ( const char * key, const type * item )</div></li><li><div class=fn>bool <a href="#remove"><b>remove</b></a> ( const char * key )</div></li><li><div class=fn>type * <a href="#take"><b>take</b></a> ( const char * key )</div></li><li><div class=fn>type * <a href="#find"><b>find</b></a> ( const char * key ) const</div></li><li><div class=fn>type * <a href="#operator[]"><b>operator[]</b></a> ( const char * 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 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 enable )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>virtual QDataStream & <a href="#read"><b>read</b></a> ( QDataStream & s, QPtrCollection::Item & item )</div></li><li><div class=fn>virtual QDataStream & <a href="#write"><b>write</b></a> ( QDataStream & s, QPtrCollection::Item ) const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2>The QAsciiDict class is a template class that provides a dictionary based on char* keys.<p> <p> <p> QAsciiDict is implemented as a template class. Define a template instanceQAsciiDict<X> to create a dictionary that operates on pointers to X (X*).<p> A dictionary is a collection of key-value pairs. The key is a char*used for insertion, removal and lookup. The value is a pointer.Dictionaries provide very fast insertion and lookup.<p> QAsciiDict cannot handle Unicode keys; use the <a href="qdict.html">QDict</a> templateinstead, which uses <a href="qstring.html">QString</a> keys. A QDict has the sameperformace as a QAsciiDict.<p> Example:<pre> QAsciiDict<QLineEdit> fields; fields.<a href="#insert">insert</a>( "forename", new <a href="qlineedit.html">QLineEdit</a>( this ) ); fields.<a href="#insert">insert</a>( "surname", new <a href="qlineedit.html">QLineEdit</a>( this ) ); fields["forename"]->setText( "Homer" ); fields["surname"]->setText( "Simpson" ); <a href="qasciidictiterator.html">QAsciiDictIterator</a><QLineEdit> it( fields ); // See QAsciiDictIterator for( ; it.<a href="qasciidictiterator.html#current">current</a>(); ++it ) cout << it.<a href="qasciidictiterator.html#currentKey">currentKey</a>() << ": " << it.<a href="qasciidictiterator.html#current">current</a>()->text() << endl; cout << endl; if ( fields["forename"] && fields["surname"] ) cout << fields["forename"]->text() << " " << fields["surname"]->text() << endl; // Prints "Homer Simpson" fields.<a href="#remove">remove</a>( "forename" ); // Does not delete the line edit if ( ! fields["forename"] ) cout << "forename is not in the dictionary" << endl; </pre> In this example we use a dictionary to keep track of the lineedits we're using. We insert each line edit into the dictionarywith a unique name and then access the line edits via thedictionary. See <a href="qptrdict.html">QPtrDict</a>, <a href="qintdict.html">QIntDict</a> and <a href="qdict.html">QDict</a>.<p> See QDict for full details, including the choice of dictionarysize, and how deletions are handled. <p> <p>See also <a href="qasciidictiterator.html">QAsciiDictIterator</a>, <a href="qdict.html">QDict</a>, <a href="qintdict.html">QIntDict</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="QAsciiDict"></a>QAsciiDict::QAsciiDict ( int size = 17, bool caseSensitive = TRUE, bool copyKeys = TRUE )</h3><p> Constructs a dictionary optimized for less than <em>size</em> entries.<p> We recommend setting <em>size</em> to a suitably large prime number (a bitlarger than the expected number of entries). This makes the hashdistribution better and hence the lookup faster.<p> When <em>caseSensitive</em> is TRUE (the default) QAsciiDict treats "abc"and "Abc" as different keys; when it is FALSE "abc" and "Abc" arethe same. Case-insensitive comparison includes only the 26 lettersin US-ASCII.<p> If <em>copyKeys</em> is TRUE (the default), the dictionary copies keysusing strcpy; if it is FALSE, the dictionary just copies thepointers.<h3 class=fn><a name="QAsciiDict-2"></a>QAsciiDict::QAsciiDict ( const <a href="qasciidict.html">QAsciiDict</a><type> & 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="~QAsciiDict"></a>QAsciiDict::~QAsciiDict ()</h3>Removes all items from the dictionary and destroys it.<p> The items are deleted if auto-delete is enabled.<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>QAsciiDict::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 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>QAsciiDict::count () const<tt> [virtual]</tt></h3>Returns the number of items in the dictionary.<p>See also <a href="#isEmpty">isEmpty</a>().
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?