⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qptrlist.3qt

📁 Linux下的基于X11的图形开发环境。
💻 3QT
📖 第 1 页 / 共 2 页
字号:
inSort() requires that compareItems() is implemented as described here..PPThis function should not modify the list because some const functions call compareItems()..PPThe default implementation compares the pointers..SH "uint QPtrList::contains ( const type * item ) const"Returns the number of occurrences of \fIitem\fR in the list..PPThe compareItems() function is called when looking for the \fIitem\fR in the list. If compareItems() is not reimplemented, it is more efficient to call containsRef()..PPThis function does not affect the current list item..PPSee also containsRef() and compareItems()..SH "uint QPtrList::containsRef ( const type * item ) const"Returns the number of occurrences of \fIitem\fR in the list..PPCalling this function is much faster than contains() because contains() compares \fIitem\fR with each list item using compareItems(), whereas his function only compares the pointers..PPThis function does not affect the current list item..PPSee also contains()..SH "uint QPtrList::count () const\fC [virtual]\fR"Returns the number of items in the list..PPSee also isEmpty()..PPExamples:.)l customlayout/border.cpp, customlayout/card.cpp, customlayout/flow.cpp, dirview/dirview.cpp, fileiconview/qfileiconview.cpp, mdi/application.cpp, and qwerty/qwerty.cpp..PPReimplemented from QPtrCollection..SH "type * QPtrList::current () const"Returns a pointer to the current list item. The current item may be 0 (implies that the current index is -1)..PPSee also at()..SH "QLNode * QPtrList::currentNode () const"Returns a pointer to the current list node..PPThe node can be kept and removed later using removeNode(). The advantage is that the item can be removed directly without searching the list..PP\fBWarning:\fR Do not call this function unless you are an expert..PPSee also removeNode(), takeNode(), and current()..SH "int QPtrList::find ( const type * item )"Finds the first occurrence of \fIitem\fR in the list..PPIf the item is found, the list sets the current item to point to the found item and returns the index of this item. If the item is not found, the list sets the current item to 0, the current index to -1, and returns -1..PPThe compareItems() function is called when searching for the item in the list. If compareItems() is not reimplemented, it is more efficient to call findRef()..PPSee also findNext(), findRef(), compareItems(), and current()..SH "int QPtrList::findNext ( const type * item )"Finds the next occurrence of \fIitem\fR in the list, starting from the current list item..PPIf the item is found, the list sets the current item to point to the found item and returns the index of this item. If the item is not found, the list sets the current item to 0, the current index to -1, and returns -1..PPThe compareItems() function is called when searching for the item in the list. If compareItems() is not reimplemented, it is more efficient to call findNextRef()..PPSee also find(), findNextRef(), compareItems(), and current()..SH "int QPtrList::findNextRef ( const type * item )"Finds the next occurrence of \fIitem\fR in the list, starting from the current list item..PPIf the item is found, the list sets the current item to point to the found item and returns the index of this item. If the item is not found, the list sets the current item to 0, the current index to -1, and returns -1..PPCalling this function is much faster than findNext() because findNext() compares \fIitem\fR with each list item using compareItems(), whereas this function only compares the pointers..PPSee also findRef(), findNext(), and current()..SH "int QPtrList::findRef ( const type * item )"Finds the first occurrence of \fIitem\fR in the list..PPIf the item is found, the list sets the current item to point to the found item and returns the index of this item. If the item is not found, the list sets the current item to 0, the current index to -1, and returns -1..PPCalling this function is much faster than find() because find() compares \fIitem\fR with each list item using compareItems(), whereas this function only compares the pointers..PPSee also findNextRef(), find(), and current()..SH "type * QPtrList::first ()"Returns a pointer to the first item in the list and makes this the current list item; returns 0 if the list is empty..PPSee also getFirst(), last(), next(), prev(), and current()..PPExamples:.)l listviews/listviews.h and showimg/showimg.cpp..SH "type * QPtrList::getFirst () const"Returns a pointer to the first item in the list, or 0 if the list is empty..PPThis function does not affect the current list item..PPSee also first() and getLast()..SH "type * QPtrList::getLast () const"Returns a pointer to the last item in the list, or 0 if the list is empty..PPThis function does not affect the current list item..PPSee also last() and getFirst()..SH "void QPtrList::inSort ( const type * item )"Inserts the \fIitem\fR at its sorted position in the list..PPThe sort order depends on the virtual compareItems() function. All items must be inserted with inSort() to maintain the sorting order..PPThe inserted item becomes the current list item..PP\fIitem\fR must not be 0..PP\fBWarning:\fR Using inSort() is slow. An alternative, especially if you have lots of items, is to simply append() or insert() them and then use sort(). inSort() takes up to O(n) compares. That means inserting n items in your list will need O(n^2) compares whereas sort() only needs O(n*log n) for the same task. So use inSort() only if you already have a presorted list and want to insert just a few additional items..PPSee also insert(), compareItems(), current(), and sort()..SH "bool QPtrList::insert ( uint index, const type * item )"Inserts the \fIitem\fR at position \fIindex\fR in the list..PPReturns TRUE if successful, i.e. if \fIindex\fR is in range; otherwise returns FALSE. The valid range is 0 to count() (inclusively). The item is appended if \fIindex\fR == count()..PPThe inserted item becomes the current list item..PP\fIitem\fR must not be 0..PPSee also append(), current(), and replace()..SH "bool QPtrList::isEmpty () const"Returns TRUE if the list is empty; otherwise returns FALSE..PPSee also count()..SH "type * QPtrList::last ()"Returns a pointer to the last item in the list and makes this the current list item; returns 0 if the list is empty..PPSee also getLast(), first(), next(), prev(), and current()..SH "type * QPtrList::next ()"Returns a pointer to the item succeeding the current item. Returns 0 if the current item is 0 or equal to the last item..PPMakes the succeeding item current. If the current item before this function call was the last item, the current item will be set to 0. If the current item was 0, this function does nothing..PPSee also first(), last(), prev(), and current()..PPExamples:.)l listviews/listviews.h and showimg/showimg.cpp..SH "bool QPtrList::operator!= ( const QPtrList<type> & list ) const"Compares this list with \fIlist\fR. Returns TRUE if the lists contain different data; otherwise returns FALSE..SH "QPtrList<type> & QPtrList::operator= ( const QPtrList<type> & list )"Assigns \fIlist\fR to this list and returns a reference to this list..PPThis list is first cleared and then each item in \fIlist\fR is appended to this list. Only the pointers are copied (shallow copy) unless newItem() has been reimplemented..SH "bool QPtrList::operator== ( const QPtrList<type> & list ) const"Compares this list with \fIlist\fR. Returns TRUE if the lists contain the same data; otherwise returns FALSE..SH "void QPtrList::prepend ( const type * item )"Inserts the \fIitem\fR at the start of the list..PPThe inserted item becomes the current list item. This is equivalent to \fCinsert( 0, item )\fR..PP\fIitem\fR must not be 0..PPSee also append(), insert(), and current()..SH "type * QPtrList::prev ()"Returns a pointer to the item preceding the current item. Returns 0 if the current item is 0 or equal to the first item..PPMakes the preceding item current. If the current item before this function call was the first item, the current item will be set to 0. If the current item was 0, this function does nothing..PPSee also first(), last(), next(), and current()..SH "QDataStream & QPtrList::read ( QDataStream & s, QPtrCollection::Item & item )\fC [virtual protected]\fR"Reads a list 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 QPtrList::remove ( uint index )"Removes the item at position \fIindex\fR in the list..PPReturns TRUE if successful, i.e. if \fIindex\fR is in range; otherwise returns FALSE. The valid range is \fC0..(count() - 1)\fR inclusive..PPThe removed item is deleted if auto-deletion is enabled..PPThe item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item..PPAll list iterators that refer to the removed item will be set to point to the new current item..PPSee also take(), clear(), setAutoDelete(), current(), and removeRef()..SH "bool QPtrList::remove ()"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves the current list item..PPReturns TRUE if successful, i.e. if the current item isn't 0; otherwise returns FALSE..PPThe removed item is deleted if auto-deletion is enabled..PPThe item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the removed item will be set to point to the new current item..PPSee also take(), clear(), setAutoDelete(), current(), and removeRef()..SH "bool QPtrList::remove ( const type * item )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves the first occurrence of \fIitem\fR from the list..PPReturns TRUE if successful, i.e. if \fIitem\fR is in the list; otherwise returns FALSE..PPThe removed item is deleted if auto-deletion is enabled..PPThe compareItems() function is called when searching for the item in the list. If compareItems() is not reimplemented, it is more efficient to call removeRef()..PPThe item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the removed item will be set to point to the new current item..PPSee also removeRef(), take(), clear(), setAutoDelete(), compareItems(), and current()..SH "bool QPtrList::removeFirst ()"Removes the first item from the list. Returns TRUE if successful, i.e. if the list isn't empty; otherwise returns FALSE..PPThe removed item is deleted if auto-deletion is enabled..PPThe first item in the list becomes the new current list item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the removed item will be set to point to the new current item..PPSee also removeLast(), setAutoDelete(), current(), and remove()..SH "bool QPtrList::removeLast ()"Removes the last item from the list. Returns TRUE if successful, i.e. if the list isn't empty; otherwise returns FALSE..PPThe removed item is deleted if auto-deletion is enabled..PPThe last item in the list becomes the new current list item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the removed item will be set to point to the new current item..PPSee also removeFirst(), setAutoDelete(), and current()..SH "void QPtrList::removeNode ( QLNode * node )"Removes the \fInode\fR from the list..PPThis node must exist in the list, otherwise the program may crash..PPThe removed item is deleted if auto-deletion is enabled..PPThe first item in the list will become the new current list item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the removed item will be set to point to the item succeeding this item or to the preceding item if the removed item was the last item..PP\fBWarning:\fR Do not call this function unless you are an expert..PPSee also takeNode(), currentNode(), remove(), and removeRef()..SH "bool QPtrList::removeRef ( const type * item )"Removes the first occurrence of \fIitem\fR from the list..PPReturns TRUE if successful, i.e. if \fIitem\fR is in the list; otherwise returns FALSE..PPThe removed item is deleted if auto-deletion is enabled..PPEquivalent to:.PP.nf.br        if ( list.findRef( item ) != -1 ).br            list.remove();.br.fi.PPThe item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the removed item will be set to point to the new current item..PPSee also remove(), clear(), setAutoDelete(), and current()..SH "bool QPtrList::replace ( uint index, const type * item )"Replaces the item at position \fIindex\fR with the new \fIitem\fR..PPReturns TRUE if successful, i.e. \fIindex\fR is in the range 0 to count()-1..PPSee also append(), current(), and insert()..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 scribble/scribble.cpp and table/bigtable/main.cpp..SH "void QPtrList::sort ()"Sorts the list by the result of the virtual compareItems() function..PPThe heap sort algorithm is used for sorting. It sorts n items with O(n*log n) comparisons. This is the asymptotic optimal solution of the sorting problem..PPIf the items in your list support operator<() and operator==(), you might be better off with QSortedList because it implements the compareItems() function for you using these two operators..PPSee also inSort()..SH "type * QPtrList::take ( uint index )"Takes the item at position \fIindex\fR out of the list without deleting it (even if auto-deletion is enabled)..PPReturns a pointer to the item taken out of the list, or 0 if the index is out of range. The valid range is \fC0..(count() - 1)\fR inclusive..PPThe item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the taken item will be set to point to the new current item..PPSee also remove(), clear(), and current()..PPExamples:.)l customlayout/border.cpp, customlayout/card.cpp, and customlayout/flow.cpp..SH "type * QPtrList::take ()"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPTakes the current item out of the list without deleting it (even if auto-deletion is enabled)..PPReturns a pointer to the item taken out of the list, or 0 if the current item is 0..PPThe item after the removed item becomes the new current list item if the removed item is not the last item in the list. If the last item is removed, the new last item becomes the current item. The current item is set to 0 if the list becomes empty..PPAll list iterators that refer to the taken item will be set to point to the new current item..PPSee also remove(), clear(), and current()..SH "type * QPtrList::takeNode ( QLNode * node )"Takes the \fInode\fR out of the list without deleting its item (even if auto-deletion is enabled). Returns a pointer to the item taken out of the list..PPThis node must exist in the list, otherwise the program may crash..PPThe first item in the list becomes the new current list item..PPAll list iterators that refer to the taken item will be set to point to the item succeeding this item or to the preceding item if the taken item was the last item..PP\fBWarning:\fR Do not call this function unless you are an expert..PPSee also removeNode() and currentNode()..SH "void QPtrList::toVector ( QGVector * vec ) const"Stores all list items in the vector \fIvec\fR..PPThe vector must be of the same item type, otherwise the result will be undefined..SH "QDataStream & QPtrList::write ( QDataStream & s, QPtrCollection::Item item ) const\fC [virtual protected]\fR"Writes a list item, \fIitem\fR to the stream \fIs\fR and returns a reference to the stream..PPThe default implementation does nothing..PPSee also read()..SH "SEE ALSO".BR http://doc.trolltech.com/qptrlist.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 (qptrlist.3qt) and the Qtversion (3.1.1).

⌨️ 快捷键说明

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