📄 qlist.3qt
字号:
Calling this function is must faster than contains(), because contains() compares \fIitem\fR with each list item using compareItems(). This function only compares the pointers..PPDoes not affect the current list item..PPSee also contains()..SH "uint QList::count () const \fC[virtual]\fR"Returns the number of items in the list..PPSee also isEmpty()..PPReimplemented from QCollection..SH "type * QList::current () const"Returns a pointer to the current list item. The current item may be null (implies that the current index is -1)..PPSee also at()..SH "QLNode * QList::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 QList::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 null, 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 QList::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 null, 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 QList::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 null, the current index to -1 and returns -1..PPCalling this function is must faster than findNext(), because findNext() compares \fIitem\fR with each list item using compareItems(). This function only compares the pointers..PPSee also findRef(), findNext() and current()..SH "int QList::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 null, the current index to -1 and returns -1..PPCalling this function is must faster than find(), because find() compares \fIitem\fR with each list item using compareItems(). This function only compares the pointers..PPSee also findNextRef(), find() and current()..SH "type * QList::first ()"Returns a pointer to the first item in the list and makes this the current list item, or null if the list is empty..PPSee also getFirst(), last(), next(), prev() and current()..PPExamples:.(lgrapher/grapher.cpp.)l.SH "type * QList::getFirst () const"Returns a pointer to the first item in the list, or null if the list is empty..PPDoes not affect the current list item..PPSee also first() and getLast()..SH "type * QList::getLast () const"Returns a pointer to the last item in the list, or null if the list is empty..PPDoes not affect the current list item..PPSee also last() and getFirst()..SH "void QList::inSort ( const type * item )"Inserts the \fIitem\fR at its sorted position in the list..PPThe sort order depends on the virtual QGList::compareItems() function. All items must be inserted with inSort() to maintain the sorting order..PPThe inserted item becomes the current list item..PPThe \fIitem\fR must not be a null pointer..PPPlease note that inSort is slow. If you want to insert lots of items in a list and sort after inserting then you should use sort(). inSort() takes up to O(n) compares. That means inserting n items in your list will need O(n^2) compares while sort() only needs O(n*logn) for the same task. So you inSort() only if you already have a pre-sorted list and want to insert only few additional items..PPSee also insert(), QGList::compareItems(), current() and sort()..SH "bool QList::insert ( uint index, const type * item )"Inserts the \fIitem\fR at the position \fIindex\fR in the list..PPReturns TRUE if successful, or FALSE if \fIindex\fR is out of range. The valid range is \fC0 .. count()\fR inclusive. The item is appended if \fIindex\fR == count()..PPThe inserted item becomes the current list item..PPThe \fIitem\fR must not be a null pointer..PPSee also append() and current()..SH "bool QList::isEmpty () const"Returns TRUE if the list is empty, i.e. count() == 0. Returns FALSE otherwise..PPSee also count()..SH "type * QList::last ()"Returns a pointer to the last item in the list and makes this the current list item, or null if the list is empty..PPSee also getLast(), first(), next(), prev() and current()..SH "type * QList::next ()"Returns a pointer to the item succeeding the current item. Returns null if the current item is null 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 null. If the current item was null, this function does nothing..PPSee also first(), last(), prev() and current()..PPExamples:.(lgrapher/grapher.cpp.)l.SH "QList<type> & QList::operator= ( const QList<type> & list )"Assigns \fIlist\fR to this list and returns a reference to this list..PPThis list is first cleared, 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 QList::operator== ( const QList<type> & list ) const"Compares this list with \fIlist.\fR Retruns TRUE if the lists contain the same data, else FALSE..SH "void QList::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.PPThe \fIitem\fR must not be a null pointer..PPSee also append(), insert() and current()..SH "type * QList::prev ()"Returns a pointer to the item preceding the current item. Returns null if the current item is null 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 null. If the current item was null, this function does nothing..PPSee also first(), last(), next() and current()..SH "bool QList::remove ()"Removes the current list item..PPReturns TRUE if successful, or FALSE if the current item is null..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 null 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 QList::remove ( const type * item )"Removes the first occurrence of \fIitem\fR from the list..PPReturns TRUE if successful, or FALSE if the item could not be found in the list..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 null 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 QList::remove ( uint index )"Removes the item at position \fIindex\fR in the list..PPReturns TRUE if successful, or FALSE if \fIindex\fR is out of range. 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. The current item is set to null 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 QList::removeFirst ()"Removes the first item from the list. Returns TRUE if successful, or FALSE if the list is empty..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 null 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 QList::removeLast ()"Removes the last item from the list. Returns TRUE if successful, or FALSE if the list is empty..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 null 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 QList::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 null 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 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 QList::removeRef ( const type * item )"Removes the first occurrence of \fIitem\fR from the list..PPReturns TRUE if successful, or FALSE if the item cannot be found in the list..PPThe removed item is deleted if auto-deletion is enabled..PPThe list is scanned until the pointer \fIitem\fR is found. It is removed if it is found..PPEquivalent to:.PP.nf.br if ( list.findRef(item) != -1 ).br list.remove();.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 null 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 "void QList::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) compares. This is the asymptotic optimal solution of the sorting problem..PPIf the items in your list support operator< and operator== then you might be better off with QSortedList since it implements the compareItems() function for you using these two operators..PPSee also inSort()..SH "type * QList::take ()"Takes the current item out of the list without deleting it (even if auto-deletion is enabled). Returns a pointer to the item taken out of the list, or null if the current item is null..PPThe item after the taken item becomes the new current list item if the taken item is not the last item in the list. If the last item is taken, the new last item becomes the current item. The current item is set to null 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 * QList::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 null if the index is out of range. The valid range is \fC0 .. (count() - 1)\fR inclusive..PPThe item after the taken item becomes the new current list item if the taken item is not the last item in the list. If the last item is taken, the new last item becomes the current item. The current item is set to null 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 * QList::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 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 QList::toVector ( QGVector * vec ) const"Stores all list items in the vector \fIvec.\fR.PPThe vector must be have the same item type, otherwise the resultwill be undefined..SH "SEE ALSO".BR http://doc.trolltech.com/qlist.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 make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qlist.3qt) and the Qtversion (2.3.10).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -