?? qlistdata.cpp
字號:
*//*! \typedef QList::reference Typedef for T &. Provided for STL compatibility.*//*! \typedef QList::const_reference Typedef for const T &. Provided for STL compatibility.*//*! \fn int QList::count() const Returns the number of items in the list. This is effectively the same as size().*//*! \fn T& QList::first() Returns a reference to the first item in the list. This function assumes that the list isn't empty. \sa last(), isEmpty()*//*! \fn const T& QList::first() const \overload*//*! \fn T& QList::last() Returns a reference to the last item in the list. This function assumes that the list isn't empty. \sa first(), isEmpty()*//*! \fn const T& QList::last() const \overload*//*! \fn void QList::removeFirst() Removes the first item in the list. This is the same as removeAt(0). \sa removeAt(), takeFirst()*//*! \fn void QList::removeLast() Removes the last item in the list. This is the same as removeAt(size() - 1). \sa removeAt(), takeLast()*//*! \fn T QList::value(int i) const Returns the value at index position \a i in the list. If the index \a i is out of bounds, the function returns a \l{default-constructed value}. If you are certain that the index is going to be within bounds, you can use at() instead, which is slightly faster. \sa at(), operator[]()*//*! \fn T QList::value(int i, const T &defaultValue) const \overload If the index \a i is out of bounds, the function returns \a defaultValue.*//*! \fn void QList::push_back(const T &value) This function is provided for STL compatibility. It is equivalent to append(\a value).*//*! \fn void QList::push_front(const T &value) This function is provided for STL compatibility. It is equivalent to prepend(\a value).*//*! \fn T& QList::front() This function is provided for STL compatibility. It is equivalent to first().*//*! \fn const T& QList::front() const \overload*//*! \fn T& QList::back() This function is provided for STL compatibility. It is equivalent to last().*//*! \fn const T& QList::back() const \overload*//*! \fn void QList::pop_front() This function is provided for STL compatibility. It is equivalent to removeFirst().*//*! \fn void QList::pop_back() This function is provided for STL compatibility. It is equivalent to removeLast().*//*! \fn bool QList::empty() const This function is provided for STL compatibility. It is equivalent to isEmpty().*//*! \fn QList<T> &QList::operator+=(const QList<T> &other) Appends the items of the \a other list to this list and returns a reference to this list. \sa operator+(), append()*//*! \fn void QList::operator+=(const T &value) \overload Appends \a value to the list. \sa append(), operator<<()*//*! \fn QList<T> QList::operator+(const QList<T> &other) const Returns a list that contains all the items in this list followed by all the items in the \a other list. \sa operator+=()*//*! \fn QList<T> &QList::operator<<(const QList<T> &other) Appends the items of the \a other list to this list and returns a reference to this list. \sa operator+=(), append()*//*! \fn void QList::operator<<(const T &value) \overload Appends \a value to the list.*//*! \class QList::iterator \brief The QList::iterator class provides an STL-style non-const iterator for QList and QQueue. QList features both \l{STL-style iterators} and \l{Java-style iterators}. The STL-style iterators are more low-level and more cumbersome to use; on the other hand, they are slightly faster and, for developers who already know STL, have the advantage of familiarity. QList\<T\>::iterator allows you to iterate over a QList\<T\> (or QQueue\<T\>) and to modify the list item associated with the iterator. If you want to iterate over a const QList, use QList::const_iterator instead. It is generally good practice to use QList::const_iterator on a non-const QList as well, unless you need to change the QList through the iterator. Const iterators are slightly faster, and can improve code readability. The default QList::iterator constructor creates an uninitialized iterator. You must initialize it using a QList function like QList::begin(), QList::end(), or QList::insert() before you can start iterating. Here's a typical loop that prints all the items stored in a list: \code QList<QString> list; list.append("January"); list.append("February"); ... list.append("December"); QList<QString>::iterator i; for (i = list.begin(); i != list.end(); ++i) cout << *i << endl; \endcode Let's see a few examples of things we can do with a QList::iterator that we cannot do with a QList::const_iterator. Here's an example that increments every value stored in a QList\<int\> by 2: \code QList<int>::iterator i; for (i = list.begin(); i != list.end(); ++i) *i += 2; \endcode Most QList functions accept an integer index rather than an iterator. For that reason, iterators are rarely useful in connection with QList. One place where STL-style iterators do make sense is as arguments to \l{generic algorithms}. For example, here's how to delete all the widgets stored in a QList\<QWidget *\>: \code QList<QWidget *> list; ... qDeleteAll(list.begin(), list.end()); \endcode Multiple iterators can be used on the same list. However, be aware that any non-const function call performed on the QList will render all existing iterators undefined. If you need to keep iterators over a long period of time, we recommend that you use QLinkedList rather than QList. \sa QList::const_iterator, QMutableListIterator*//*! \typedef QList::iterator::iterator_category \internal*//*! \typedef QList::iterator::difference_type \internal*//*! \typedef QList::iterator::value_type \internal*//*! \typedef QList::iterator::pointer \internal*//*! \typedef QList::iterator::reference \internal*//*! \fn QList::iterator::iterator() Constructs an uninitialized iterator. Functions like operator*() and operator++() should not be called on an uninitialized iterartor. Use operator=() to assign a value to it before using it. \sa QList::begin() QList::end()*//*! \fn QList::iterator::iterator(Node *node) \internal*//*! \fn QList::iterator::iterator(const iterator &other) Constructs a copy of \a other.*//*! \fn T &QList::iterator::operator*() const Returns a modifiable reference to the current item. You can change the value of an item by using operator*() on the left side of an assignment, for example: \code if (*it == "Hello") *it = "Bonjour"; \endcode \sa operator->()*//*! \fn T *QList::iterator::operator->() const Returns a pointer to the current item. \sa operator*()*//*! \fn T &QList::iterator::operator[](int j) const Returns a modifiable reference to the item at position *this + \a{j}. This function is provided to make QList iterators behave like C++ pointers. \sa operator+()*//*! \fn bool QList::iterator::operator==(const iterator &other) const \fn bool QList::iterator::operator==(const const_iterator &other) const Returns true if \a other points to the same item as this iterator; otherwise returns false. \sa operator!=()*//*! \fn bool QList::iterator::operator!=(const iterator &other) const \fn bool QList::iterator::operator!=(const const_iterator &other) const Returns true if \a other points to a different item than this iterator; otherwise returns false. \sa operator==()*//*! \fn bool QList::iterator::operator<(const iterator& other) const \fn bool QList::iterator::operator<(const const_iterator& other) const Returns true if the item pointed to by this iterator is less than the item pointed to by the \a other iterator.*//*! \fn bool QList::iterator::operator<=(const iterator& other) const \fn bool QList::iterator::operator<=(const const_iterator& other) const Returns true if the item pointed to by this iterator is less than or equal to the item pointed to by the \a other iterator.*//*! \fn bool QList::iterator::operator>(const iterator& other) const \fn bool QList::iterator::operator>(const const_iterator& other) const Returns true if the item pointed to by this iterator is greater than the item pointed to by the \a other iterator.*//*! \fn bool QList::iterator::operator>=(const iterator& other) const \fn bool QList::iterator::operator>=(const const_iterator& other) const Returns true if the item pointed to by this iterator is greater than or equal to the item pointed to by the \a other iterator.*//*! \fn QList::iterator &QList::iterator::operator++() The prefix ++ operator (\c{++it}) advances the iterator to the next item in the list and returns an iterator to the new current item. Calling this function on QList::end() leads to undefined results. \sa operator--()*//*! \fn QList::iterator QList::iterator::operator++(int) \overload The postfix ++ operator (\c{it++}) advances the iterator to the next item in the list and returns an iterator to the previously current item.*//*! \fn QList::iterator &QList::iterator::operator--() The prefix -- operator (\c{--it}) makes the preceding item current and returns an iterator to the new current item. Calling this function on QList::begin() leads to undefined results. \sa operator++()*//*! \fn QList::iterator QList::iterator::operator--(int) \overload The postfix -- operator (\c{it--}) makes the preceding item current and returns an iterator to the previously current item.*//*! \fn QList::iterator &QList::iterator::operator+=(int j) Advances the iterator by \a j items. (If \a j is negative, the iterator goes backward.) \sa operator-=(), operator+()*//*! \fn QList::iterator &QList::iterator::operator-=(int j) Makes the iterator go back by \a j items. (If \a j is negative, the iterator goes forward.) \sa operator+=(), operator-()*//*! \fn QList::iterator QList::iterator::operator+(int j) const Returns an iterator to the item at \a j positions forward from this iterator. (If \a j is negative, the iterator goes backward.) \sa operator-(), operator+=()*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -