📄 qvaluelist.3qt
字号:
.br QValueList<double> dlist;.br double d = dlist.last(); // undefined.fi.PPBecause QValueList is value-based there is no need to be careful about deleting items in the list. The list holds its own copies and will free them if the corresponding member or the list itself is deleted. You can force the list to free all of its items with clear()..PPQValueList is shared implicitly, which means it can be copied in constant time. If multiple QValueList instances share the same data and one needs to modify its contents, this modifying instance makes a copy and modifies its private copy; therefore it not affect the other instances. This is often called "copy on write". If a QValueList is being used in a multi-threaded program, you must protect all access to the list. See QMutex..PPThere are several ways to insert items into the list. The prepend() and append() functions insert items at the beginning and the end of the list respectively. The insert() function comes in several flavors and can be used to add one or more items at specific positions within the list..PPItems can be also be removed from the list in several ways. There are several variants of the remove() function, which removes a specific item from the list. The remove() function will find and remove items according to a specific item value..PPLists can be also sorted with the sort() function, or can be sorted using the Qt Template Library. For example with qHeapSort():.PPExample:.PP.nf.br QValueList<int> l;.br l.append( 5 );.br l.append( 8 );.br l.append( 3 );.br l.append( 4 );.br qHeapSort( l );.br.fi.PPSee also QValueListIterator, Qt Template Library Classes, Implicitly and Explicitly Shared Classes and Non-GUI Classes..SS "Member Type Documentation".SH "QValueList::ConstIterator"This iterator is an instantiation of QValueListConstIterator for the same type as this QValueList. In other words, if you instantiate QValueList<int>, ConstIterator is a QValueListConstIterator<int>. Several member function use it, such as QValueList::begin(), which returns an iterator pointing to the first item in the list..PPFunctionally, this is almost the same as Iterator. The only difference is you cannot use ConstIterator for non-const operations, and that the compiler often can generate better code if you use ConstIterator..PPSee also QValueListIterator and Iterator..SH "QValueList::Iterator"This iterator is an instantiation of QValueListIterator for the same type as this QValueList. In other words, if you instantiate QValueList<int>, Iterator is a QValueListIterator<int>. Several member function use it, such as QValueList::begin(), which returns an iterator pointing to the first item in the list..PPFunctionally, this is almost the same as ConstIterator. The only difference is you cannot use ConstIterator for non-const operations, and that the compiler often can generate better code if you use ConstIterator..PPSee also QValueListIterator and ConstIterator..SH "QValueList::const_iterator"The list's const iterator type, QValueListConstIterator..SH "QValueList::const_pointer"The const pointer to T type..SH "QValueList::const_reference"The const reference to T type..SH "QValueList::iterator"The list's iterator type, QValueListIterator..SH "QValueList::pointer"The pointer to T type..SH "QValueList::reference"The reference to T type..SH "QValueList::size_type"An unsigned integral type, used to represent various sizes..SH "QValueList::value_type"The type of the object stored in the list, T..SH MEMBER FUNCTION DOCUMENTATION.SH "QValueList::QValueList ()"Constructs an empty list..SH "QValueList::QValueList ( const QValueList<T> & l )"Constructs a copy of \fIl\fR..PPThis operation takes O(1) time because QValueList is shared implicitly..PPThe first modification to a list will take O(n) time..SH "QValueList::QValueList ( const std::list<T> & l )"Contructs a copy of \fIl\fR..PPThis constructor is provided for compatibility with STL containers..SH "QValueList::~QValueList ()"Destroys the list. References to the values in the list and all iterators of this list become invalidated. Note that it is impossible for an iterator to check whether or not it is valid - QValueList is highly tuned for performance, not for error checking..SH "iterator QValueList::append ( const T & x )"Inserts \fIx\fR at the end of the list..PPSee also insert() and prepend()..PPExamples:.)l checklists/checklists.cpp and fonts/simple-qfont-demo/viewer.cpp..SH "const_iterator QValueList::at ( size_type i ) const"Returns an iterator pointing to the item at position \fIi\fR in the list, or end() if the index is out of range..PP\fBWarning:\fR This function uses a linear search and can be extremely slow for large lists. QValueList is not optimized for random item access. If you need random access use a different container, such as QValueVector..SH "iterator QValueList::at ( size_type i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns an iterator pointing to the item at position \fIi\fR in the list, or end() if the index is out of range..SH "reference QValueList::back ()"Returns a reference to the last item. If the list contains no last item (i.e. empty() returns TRUE), the return value is undefined..PPThis function is provided for STL compatibility. It is equivalent to last()..PPSee also front()..SH "const_reference QValueList::back () const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "const_iterator QValueList::begin () const"Returns an iterator pointing to the first item in the list. This iterator equals end() if the list is empty..PPSee also first() and end()..PPExamples:.)l checklists/checklists.cpp, dirview/dirview.cpp, fonts/simple-qfont-demo/viewer.cpp, network/ftpclient/ftpmainwindow.cpp, network/ftpclient/ftpview.cpp and sql/overview/insert/main.cpp..SH "iterator QValueList::begin ()"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns an iterator pointing to the first item in the list. This iterator equals end() if the list is empty..PPSee also first() and end()..SH "void QValueList::clear ()"Removes all items from the list..PPSee also remove()..SH "size_type QValueList::contains ( const T & x ) const"Returns the number of occurrences of the value \fIx\fR in the list..SH "size_type QValueList::count () const"Returns the number of items in the list..PPSee also isEmpty()..SH "bool QValueList::empty () const"Returns TRUE if the list contains no items; otherwise returns FALSE..PPSee also size()..SH "iterator QValueList::end ()"Returns an iterator pointing behind the last item in the list. This iterator equals begin() if the list is empty..PPSee also last() and begin()..PPExamples:.)l checklists/checklists.cpp, dirview/dirview.cpp, fonts/simple-qfont-demo/viewer.cpp, network/ftpclient/ftpmainwindow.cpp, network/ftpclient/ftpview.cpp and sql/overview/insert/main.cpp..SH "const_iterator QValueList::end () const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns an iterator pointing behind the last item in the list. This iterator equals begin() if the list is empty..PPSee also last() and begin()..SH "iterator QValueList::erase ( iterator it )"Removes the item pointed to by \fIit\fR from the list. No iterators other than \fIit\fR or other iterators pointing at the same item as \fIit\fR are invalidated. Returns an iterator to the next item after \fIit\fR, or end() if there is no such item..PPThis function is provided for STL compatibility. It is equivalent to remove()..SH "iterator QValueList::erase ( iterator first, iterator last )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPDeletes all items from \fIfirst\fR to \fIlast\fR (not including \fIlast\fR). No iterators are invalidated, except those pointing to the removed items themselves. Returns \fIlast\fR..SH "iterator QValueList::find ( const T & x )"Returns an iterator pointing to the first occurrence of \fIx\fR in the list..PPReturns end() is no item matched..SH "const_iterator QValueList::find ( const T & x ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns an iterator pointing to the first occurrence of \fIx\fR in the list..PPReturns end() is no item matched..SH "iterator QValueList::find ( iterator it, const T & x )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of \fIx\fR in the list starting at the position given by \fIit\fR..PPReturns end() if no item matched..SH "const_iterator QValueList::find ( const_iterator it, const T & x ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPFinds the first occurrence of \fIx\fR in the list starting at the position given by \fIit\fR. Returns end() if no item matched..SH "int QValueList::findIndex ( const T & x ) const"Returns the index of the first occurrence of the value \fIx\fR. Returns -1 if no item matched..SH "T & QValueList::first ()"Returns a reference to the first item. If the list contains no first item (i.e. isEmpty() returns TRUE), the return value is undefined..PPSee also last()..PPExample: network/mail/smtp.cpp..SH "const T & QValueList::first () const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "const_iterator QValueList::fromLast () const"Returns an iterator to the last item in the list, or end() if there is no last item..PPUse the end() function instead. For example:.PP.nf.br QValueList<int> l;.br ....br QValueList<int>::iterator it = l.end();.br --it;.br if ( it != end() ).br // ....fi.SH "iterator QValueList::fromLast ()"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns an iterator to the last item in the list, or end() if there is no last item..PPUse the end() function instead. For example:.PP.nf.br QValueList<int> l;.br ....br QValueList<int>::iterator it = l.end();.br --it;.br if ( it != end() ).br // ....fi.SH "reference QValueList::front ()"Returns a reference to the first item. If the list contains no first item (i.e. empty() returns TRUE), the return value is undefined..PPThis function is provided for STL compatibility. It is equivalent to first()..PPSee also back()..SH "const_reference QValueList::front () const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "iterator QValueList::insert ( iterator it, const T & x )"Inserts the value \fIx\fR in front of the iterator \fIit\fR..PPReturns an iterator pointing at the inserted item..PPSee also append() and prepend()..SH "void QValueList::insert ( iterator pos, size_type n, const T & x )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPInserts \fIn\fR copies of \fIx\fR before position \fIpos\fR..SH "bool QValueList::isEmpty () const"Returns TRUE if the list contains no items; otherwise returns FALSE..PPSee also count()..PPExamples:.)l fonts/simple-qfont-demo/viewer.cpp, network/ftpclient/ftpmainwindow.cpp and network/mail/smtp.cpp..SH "T & QValueList::last ()"Returns a reference to the last item. If the list contains no last item (i.e. empty() returns TRUE), the return value is undefined..SH "const T & QValueList::last () const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..SH "bool QValueList::operator!= ( const QValueList<T> & l ) const"Compares both lists..PPReturns TRUE if this list and \fIl\fR are unequal; otherwise returns FALSE..SH "QValueList<T> QValueList::operator+ ( const QValueList<T> & l ) const"Creates a new list and fills it with the items of this list. Then the items of \fIl\fR are appended. Returns the new list..SH "QValueList<T> & QValueList::operator+= ( const QValueList<T> & l )"Appends the items of \fIl\fR to this list. Returns a reference to this list..SH "QValueList<T> & QValueList::operator+= ( const T & x )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAppends the value \fIx\fR to the list. Returns a reference to the list..SH "QValueList<T> & QValueList::operator<< ( const T & x )"Adds the value \fIx\fR to the end of the list..PPReturns a reference to the list..SH "QValueList<T> & QValueList::operator= ( const QValueList<T> & l )"Assigns \fIl\fR to this list and returns a reference to this list..PPAll iterators of the current list become invalidated by this operation. The cost of such an assignment is O(1) since QValueList is implicitly shared..SH "QValueList<T> & QValueList::operator= ( const std::list<T> & l )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPAssigns the contents of \fIl\fR to the list..PPAll iterators of the current list become invalidated by this operation..SH "bool QValueList::operator== ( const QValueList<T> & l ) const"Compares both lists..PPReturns TRUE if this list and \fIl\fR are equal; otherwise returns FALSE..SH "bool QValueList::operator== ( const std::list<T> & l ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns TRUE if this list and \fIl\fR are equal; otherwise returns FALSE..PPThis operator is provided for compatibility with STL containers..SH "const T & QValueList::operator[] ( size_type i ) const"Returns a const reference to the item with index \fIi\fR in the list. It is up to you to check whether this item really exists. You can do that easily with the count() function. However this operator does not check whether \fIi\fR is in range and will deliver undefined results if it does not exist..PP\fBWarning:\fR This function uses a linear search and can be extremely slow for large lists. QValueList is not optimized for random item access. If you need random access use a different container, such as QValueVector..SH "T & QValueList::operator[] ( size_type i )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPReturns a non-const reference to the item with index \fIi\fR..SH "void QValueList::pop_back ()"Removes the last item. If there is no last item, this operation is undefined..PPThis function is provided for STL compatibility..SH "void QValueList::pop_front ()"Removes the first item. If there is no first item, this operation is undefined..PPThis function is provided for STL compatibility..SH "iterator QValueList::prepend ( const T & x )"Inserts \fIx\fR at the beginning of the list..PPSee also insert() and append()..SH "void QValueList::push_back ( const T & x )"Inserts \fIx\fR at the end of the list..PPThis function is provided for STL compatibility. It is equivalent to append()..SH "void QValueList::push_front ( const T & x )"Inserts \fIx\fR at the beginning of the list..PPThis function is provided for STL compatibility. It is equivalent to prepend()..SH "iterator QValueList::remove ( iterator it )"Removes the item pointed to by \fIit\fR from the list. No iterators other than \fIit\fR or other iterators pointing at the same item as \fIit\fR are invalidated. Returns an iterator to the next item after \fIit\fR, or end() if there is no such item..PPSee also clear()..SH "uint QValueList::remove ( const T & x )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPRemoves all items that have value \fIx\fR and returns the number of removed items..SH "size_type QValueList::size () const"Returns the number of items in the list..PPThis function is provided for STL compatibility. It is equivalent to count()..PPSee also empty()..PPExample: network/ftpclient/ftpview.cpp..SH RELATED FUNCTION DOCUMENTATION.SH "QDataStream & operator<< ( QDataStream & s, const QValueList<T> & l )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPWrites a list, \fIl\fR, to the stream \fIs\fR. The type T stored in the list must implement the streaming operator, too..SH "QDataStream & operator>> ( QDataStream & s, QValueList<T> & l )"Reads a list, \fIl\fR, from the stream \fIs\fR. The type T stored in thelist must implement the streaming operator, too..SH "SEE ALSO".BR http://doc.trolltech.com/qvaluelist.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 (qvaluelist.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -