📄 qintdict.3qt
字号:
'\" t.TH QIntDict 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQIntDict \- Template class that provides a dictionary based on long keys.PP\fC#include <qintdict.h>\fR.PPInherits QPtrCollection..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQIntDict\fR ( int size = 17 )".br.ti -1c.BI "\fBQIntDict\fR ( const QIntDict<type> & dict )".br.ti -1c.BI "\fB~QIntDict\fR ()".br.ti -1c.BI "QIntDict<type> & \fBoperator=\fR ( const QIntDict<type> & dict )".br.ti -1c.BI "virtual uint \fBcount\fR () const".br.ti -1c.BI "uint \fBsize\fR () const".br.ti -1c.BI "bool \fBisEmpty\fR () const".br.ti -1c.BI "void \fBinsert\fR ( long key, const type * item )".br.ti -1c.BI "void \fBreplace\fR ( long key, const type * item )".br.ti -1c.BI "bool \fBremove\fR ( long key )".br.ti -1c.BI "type * \fBtake\fR ( long key )".br.ti -1c.BI "type * \fBfind\fR ( long key ) const".br.ti -1c.BI "type * \fBoperator[]\fR ( long key ) const".br.ti -1c.BI "virtual void \fBclear\fR ()".br.ti -1c.BI "void \fBresize\fR ( uint newsize )".br.ti -1c.BI "void \fBstatistics\fR () const".br.in -1c.SS "Important Inherited Members".in +1c.ti -1c.BI "bool \fBautoDelete\fR () const".br.ti -1c.BI "void \fBsetAutoDelete\fR ( bool enable )".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual QDataStream & \fBread\fR ( QDataStream & s, QPtrCollection::Item & item )".br.ti -1c.BI "virtual QDataStream & \fBwrite\fR ( QDataStream & s, QPtrCollection::Item ) const".br.in -1c.SH DESCRIPTIONThe QIntDict class is a template class that provides a dictionary based on long keys..PPQIntDict is implemented as a template class. Define a template instance QIntDict<X> to create a dictionary that operates on pointers to X (X*)..PPA dictionary is a collection of key-value pairs. The key is an \fClong\fR used for insertion, removal and lookup. The value is a pointer. Dictionaries provide very fast insertion and lookup..PPExample:.PP.nf.br QIntDict<QLineEdit> fields;.br for ( int i = 0; i < 3; i++ ).br fields.insert( i, new QLineEdit( this ) );.br.br fields[0]->setText( "Homer" );.br fields[1]->setText( "Simpson" );.br fields[2]->setText( "45" );.br.br QIntDictIterator<char> it( fields ); // See QIntDictIterator.br for ( ; it.current(); ++it ).br cout << it.currentKey() << ": " << it.current()->text() << endl;.br.br.br for ( int i = 0; i < 3; i++ ).br cout << fields[i]->text() << " "; // Prints "Homer Simpson 45".br cout << endl;.br.br fields.remove( 1 ); // Does not delete the line edit.br for ( int i = 0; i < 3; i++ ).br if ( fields[i] ).br cout << fields[i]->text() << " "; // Prints "Homer 45".br.fi.PPSee QDict for full details, including the choice of dictionary size, and how deletions are handled..PPSee also QIntDictIterator, QDict, QAsciiDict, QPtrDict, Collection Classes, Collection Classes and Non-GUI Classes..SH MEMBER FUNCTION DOCUMENTATION.SH "QIntDict::QIntDict ( int size = 17 )"Constructs a dictionary using an internal hash array of size \fIsize\fR..PPSetting \fIsize\fR to a suitably large prime number (equal to or greater than the expected number of entries) makes the hash distribution better and hence the lookup faster..SH "QIntDict::QIntDict ( const QIntDict<type> & dict )"Constructs a copy of \fIdict\fR..PPEach item in \fIdict\fR is inserted into this dictionary. Only the pointers are copied (shallow copy)..SH "QIntDict::~QIntDict ()"Removes all items from the dictionary and destroys it..PPAll iterators that access this dictionary will be reset..PPSee also setAutoDelete()..SH "bool QPtrCollection::autoDelete () const"Returns the setting of the auto-delete option. The default is FALSE..PPSee also setAutoDelete()..SH "void QIntDict::clear ()\fC [virtual]\fR"Removes all items from the dictionary..PPThe removed items are deleted if auto-deletion is enabled..PPAll dictionary iterators that access this dictionary will be reset..PPSee also remove(), take() and setAutoDelete()..PPReimplemented from QPtrCollection..SH "uint QIntDict::count () const\fC [virtual]\fR"Returns the number of items in the dictionary..PPSee also isEmpty()..PPReimplemented from QPtrCollection..SH "type * QIntDict::find ( long key ) const"Returns the item associated with \fIkey\fR, or null if the key does not exist in the dictionary..PPThis function uses an internal hashing algorithm to optimize lookup..PPIf there are two or more items with equal keys, then the last inserted of these will be found..PPEquivalent to the [] operator..PPSee also operator[]()..PPExample: table/bigtable/main.cpp..SH "void QIntDict::insert ( long key, const type * item )"Insert item \fIitem\fR into the dictionary using key \fIkey\fR..PPThe key does not have to be unique. If multiple items are inserted with the same key, only the last item will be visible..PPNull items are not allowed..PPSee also replace()..PPExample: scribble/scribble.cpp..SH "bool QIntDict::isEmpty () const"Returns TRUE if the dictionary is empty; otherwise returns FALSE..PPSee also count()..SH "QIntDict<type> & QIntDict::operator= ( const QIntDict<type> & dict )"Assigns \fIdict\fR to this dictionary and returns a reference to this dictionary..PPThis dictionary is first cleared and then each item in \fIdict\fR is inserted into this dictionary. Only the pointers are copied (shallow copy), unless newItem() has been reimplemented..SH "type * QIntDict::operator[] ( long key ) const"Returns the item associated with \fIkey\fR, or null if the key does not exist in the dictionary..PPThis function uses an internal hashing algorithm to optimize lookup..PPIf there are two or more items with equal keys, then the last inserted of these will be found..PPEquivalent to the find() function..PPSee also find()..SH "QDataStream & QIntDict::read ( QDataStream & s, QPtrCollection::Item & item )\fC [virtual protected]\fR"Reads a dictionary item from the stream \fIs\fR and returns a reference to the stream..PPThe default implementation sets \fIitem\fR to 0..PPSee also write()..SH "bool QIntDict::remove ( long key )"Removes the item associated with \fIkey\fR from the dictionary. Returns TRUE if successful; otherwise returns FALSE, e.g. if the key does not exist in the dictionary..PPIf there are two or more items with equal keys, then the last inserted of these will be removed..PPThe removed item is deleted if auto-deletion is enabled..PPAll dictionary iterators that refer to the removed item will be set to point to the next item in the dictionary's traversing order..PPSee also take(), clear() and setAutoDelete()..PPExample: table/bigtable/main.cpp..SH "void QIntDict::replace ( long key, const type * item )"If the dictionary has key \fIkey\fR, this key's item is replaced with \fIitem\fR. If the dictionary doesn't contain key \fIkey\fR, \fIitem\fR is inserted into the dictionary using key \fIkey\fR..PPNull items are not allowed..PPEquivalent to:.PP.nf.br QIntDict<char> dict;.br // ....br if ( dict.find(key) ).br dict.remove( key );.br dict.insert( key, item );.br.fi.PPIf there are two or more items with equal keys, then the last inserted of these will be replaced..PPSee also insert()..PPExample: table/bigtable/main.cpp..SH "void QIntDict::resize ( uint newsize )"Changes the size of the hashtable to \fInewsize\fR. The contents of the dictionary are preserved, but all iterators on the dictionary become invalid..SH "void QPtrCollection::setAutoDelete ( bool enable )"Sets the collection to auto-delete its contents if \fIenable\fR is TRUE and to never delete them if \fIenable\fR is FALSE..PPIf auto-deleting is turned on, all the items in a collection are deleted when the collection itself is deleted. This is convenient if the collection has the only pointer to the items..PPThe default setting is FALSE, for safety. If you turn it on, be careful about copying the collection - you might find yourself with two collections deleting the same items..PPNote that the auto-delete setting may also affect other functions in subclasses. For example, a subclass that has a remove() function will remove the item from its data structure, and if auto-delete is enabled, will also delete the item..PPSee also autoDelete()..PPExamples:.)l grapher/grapher.cpp, scribble/scribble.cpp and table/bigtable/main.cpp..SH "uint QIntDict::size () const"Returns the size of the internal hash array (as specified in the constructor)..PPSee also count()..SH "void QIntDict::statistics () const"Debugging-only function that prints out the dictionary distribution using qDebug()..SH "type * QIntDict::take ( long key )"Takes the item associated with \fIkey\fR out of the dictionary without deleting it (even if auto-deletion is enabled)..PPIf there are two or more items with equal keys, then the last inserted of these will be taken..PPReturns a pointer to the item taken out, or null if the key does not exist in the dictionary..PPAll dictionary iterators that refer to the taken item will be set to point to the next item in the dictionary's traversing order..PPSee also remove(), clear() and setAutoDelete()..SH "QDataStream & QIntDict::write ( QDataStream & s, QPtrCollection::Item ) const\fC [virtual protected]\fR"Writes a dictionary item to the stream \fIs\fR and returns a reference to the stream..PPSee also read()..SH "SEE ALSO".BR http://doc.trolltech.com/qintdict.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qintdict.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -