📄 qlistdata.cpp
字号:
Constructs a copy of \a other. This operation takes \l{constant time}, because QList is \l{implicitly shared}. This makes returning a QList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes \l{linear time}. \sa operator=()*//*! \fn QList::~QList() Destroys the list. References to the values in the list and all iterators of this list become invalid.*//*! \fn QList<T> &QList::operator=(const QList<T> &other) Assigns \a other to this list and returns a reference to this list.*//*! \fn bool QList::operator==(const QList<T> &other) const Returns true if \a other is equal to this list; otherwise returns false. Two lists are considered equal if they contain the same values in the same order. This function requires the value type to have an implementation of \c operator==(). \sa operator!=()*//*! \fn bool QList::operator!=(const QList<T> &other) const Returns true if \a other is not equal to this list; otherwise returns false. Two lists are considered equal if they contain the same values in the same order. This function requires the value type to have an implementation of \c operator==(). \sa operator==()*//*! \fn int QList::size() const Returns the number of items in the list. \sa isEmpty(), count()*//*! \fn void QList::detach() \internal*//*! \fn bool QList::isDetached() const \internal*//*! \fn void QList::setSharable(bool sharable) \internal*//*! \fn bool QList::isEmpty() const Returns true if the list contains no items; otherwise returns false. \sa size()*//*! \fn void QList::clear() Removes all items from the list. \sa removeAll()*//*! \fn const T &QList::at(int i) const Returns the item at index position \a i in the list. \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). This function is very fast (\l{constant time}). \sa value(), operator[]()*//*! \fn T &QList::operator[](int i) Returns the item at index position \a i as a modifiable reference. \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). This function is very fast (\l{constant time}). \sa at(), value()*//*! \fn const T &QList::operator[](int i) const \overload Same as at().*//*! \fn void QList::append(const T &value) Inserts \a value at the end of the list. Example: \code QList<QString> list; list.append("one"); list.append("two"); list.append("three"); // list: ["one", "two", "three"] \endcode This is the same as list.insert(size(), \a value). This operation is typically very fast (\l{constant time}), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list. \sa operator<<(), prepend(), insert()*//*! \fn void QList::prepend(const T &value) Inserts \a value at the beginning of the list. Example: \code QList<QString> list; list.prepend("one"); list.prepend("two"); list.prepend("three"); // list: ["three", "two", "one"] \endcode This is the same as list.insert(0, \a value). This operation is usually very fast (\l{constant time}), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list. \sa append(), insert()*//*! \fn void QList::insert(int i, const T &value) Inserts \a value at index position \a i in the list. If \a i is 0, the value is prepended to the list. If \a i is size(), the value is appended to the list. Example: \code QList<QString> list; list << "alpha" << "beta" << "delta"; list.insert(2, "gamma"); // list: ["alpha", "beta", "gamma", "delta"] \endcode \sa append(), prepend(), replace(), removeAt()*//*! \fn QList::iterator QList::insert(iterator before, const T &value) \overload Inserts \a value in front of the item pointed to by the iterator \a before. Returns an iterator pointing at the inserted item. Note that the iterator passed to the function will be invalid after the call; the returned iterator should be used instead.*//*! \fn void QList::replace(int i, const T &value) Replaces the item at index position \a i with \a value. \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). \sa operator[](), removeAt()*//*! \fn int QList::removeAll(const T &value) Removes all occurrences of \a value in the list and returns the number of entries removed. Example: \code QList<QString> list; list << "sun" << "cloud" << "sun" << "rain"; list.removeAll("sun"); // list: ["cloud", "rain"] \endcode This function requires the value type to have an implementation of \c operator==(). \sa removeAt(), takeAt(), replace()*//*! \fn void QList::removeAt(int i) Removes the item at index position \a i. \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). \sa takeAt(), removeFirst(), removeLast()*//*! \fn T QList::takeAt(int i) Removes the item at index position \a i and returns it. \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). If you don't use the return value, removeAt() is more efficient. \sa removeAt(), takeFirst(), takeLast()*//*! \fn T QList::takeFirst() Removes the first item in the list and returns it. This is the same as takeAt(0). This operation is very fast (\l{constant time}), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list. If you don't use the return value, removeFirst() is more efficient. \sa takeLast(), takeAt(), removeFirst()*//*! \fn T QList::takeLast() Removes the last item in the list and returns it. This is the same as takeAt(size() - 1). This operation is very fast (\l{constant time}), because QList preallocates extra space on both sides of its internal buffer to allow for fast growth at both ends of the list. If you don't use the return value, removeLast() is more efficient. \sa takeFirst(), takeAt(), removeLast()*//*! \fn void QList::move(int from, int to) Moves the item at index position \a from to index position \a to. Example: \code QList<QString> list; list << "A" << "B" << "C" << "D" << "E" << "F"; list.move(1, 4); // list: ["A", "C", "D", "E", "B", "F"] \endcode This is the same as insert(\a{to}, takeAt(\a{from})). \sa swap(), insert(), takeAt()*//*! \fn void QList::swap(int i, int j) Exchange the item at index position \a i with the item at index position \a j. Example: \code QList<QString> list; list << "A" << "B" << "C" << "D" << "E" << "F"; list.swap(1, 4); // list: ["A", "E", "C", "D", "B", "F"] \endcode \sa move()*//*! \fn int QList::indexOf(const T &value, int from = 0) const Returns the index position of the first occurrence of \a value in the list, searching forward from index position \a from. Returns -1 if no item matched. Example: \code QList<QString> list; list << "A" << "B" << "C" << "B" << "A"; list.indexOf("B"); // returns 1 list.indexOf("B", 1); // returns 1 list.indexOf("B", 2); // returns 3 list.indexOf("X"); // returns -1 \endcode This function requires the value type to have an implementation of \c operator==(). \sa lastIndexOf(), contains()*//*! \fn int QList::lastIndexOf(const T &value, int from = -1) const Returns the index position of the last occurrence of \a value in the list, searching backward from index position \a from. If \a from is -1 (the default), the search starts at the last item. Returns -1 if no item matched. Example: \code QList<QString> list; list << "A" << "B" << "C" << "B" << "A"; list.lastIndexOf("B"); // returns 3 list.lastIndexOf("B", 3); // returns 3 list.lastIndexOf("B", 2); // returns 1 list.lastIndexOf("X"); // returns -1 \endcode This function requires the value type to have an implementation of \c operator==(). \sa indexOf()*//*! \fn QBool QList::contains(const T &value) const Returns true if the list contains an occurrence of \a value; otherwise returns false. This function requires the value type to have an implementation of \c operator==(). \sa indexOf(), count()*//*! \fn int QList::count(const T &value) const Returns the number of occurrences of \a value in the list. This function requires the value type to have an implementation of \c operator==(). \sa contains(), indexOf()*//*! \fn QList::iterator QList::begin() Returns an \l{STL-style iterator} pointing to the first item in the list. \sa constBegin(), end()*//*! \fn QList::const_iterator QList::begin() const \overload*//*! \fn QList::const_iterator QList::constBegin() const Returns a const \l{STL-style iterator} pointing to the first item in the list. \sa begin(), constEnd()*//*! \fn QList::iterator QList::end() Returns an \l{STL-style iterator} pointing to the imaginary item after the last item in the list. \sa begin(), constEnd()*//*! \fn const_iterator QList::end() const \overload*//*! \fn QList::const_iterator QList::constEnd() const Returns a const \l{STL-style iterator} pointing to the imaginary item after the last item in the list. \sa constBegin(), end()*//*! \fn QList::iterator QList::erase(iterator pos) Removes the item associated with the iterator \a pos from the list, and returns an iterator to the next item in the list (which may be end()). \sa insert(), removeAt()*//*! \fn QList::iterator QList::erase(iterator begin, iterator end) \overload Removes all the items from \a begin up to (but not including) \a end. Returns an iterator to the same item that \a end referred to before the call.*//*! \typedef QList::Iterator Qt-style synonym for QList::iterator.*//*! \typedef QList::ConstIterator Qt-style synonym for QList::const_iterator.*//*! \typedef QList::size_type Typedef for int. Provided for STL compatibility.*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -