diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 9b23a9056c..e791c0c664 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -205,7 +205,7 @@ for (i = splitter->sizes().begin(); //! [15] -QVector values; +QList values; ... QString str; foreach (str, values) @@ -214,16 +214,16 @@ foreach (str, values) //! [16] -QVector values; +QList values; ... -QVectorIterator i(values); +QListIterator i(values); while (i.hasNext()) qDebug() << i.next(); //! [16] //! [17] -QVector values; +QList values; ... foreach (const QString &str, values) qDebug() << str; @@ -231,7 +231,7 @@ foreach (const QString &str, values) //! [18] -QVector values; +QList values; ... foreach (const QString &str, values) { if (str.isEmpty()) @@ -284,10 +284,10 @@ QString onlyLetters(const QString &in) //! [23] //! [24] -QVector a, b; -a.resize(100000); // make a big vector filled with 0. +QList a, b; +a.resize(100000); // make a big list filled with 0. -QVector::iterator i = a.begin(); +QList::iterator i = a.begin(); // WRONG way of using the iterator i: b = a; /* @@ -309,13 +309,13 @@ int j = *i; // Undefined behavior! /* The data from b (which i pointed to) is gone. This would be well-defined with STL containers (and (*i) == 5), - but with QVector this is likely to crash. + but with QList this is likely to crash. */ //! [24] //! [25] -QVector vector{1, 2, 3, 4, 4, 5}; -QSet set(vector.begin(), vector.end()); +QList list { 1, 2, 3, 4, 4, 5 }; +QSet set(list.begin(), list.end()); /* Will generate a QSet containing 1, 2, 4, 5. */ diff --git a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp index b86ea3d7e1..58f6b196b4 100644 --- a/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qalgorithms.cpp @@ -105,13 +105,13 @@ QChar resolveEntity(const QString &entity) QStringList list; list << "one" << "two" << "three"; -QVector vect1(3); -qCopy(list.begin(), list.end(), vect1.begin()); -// vect: [ "one", "two", "three" ] +QList list1(3); +qCopy(list.begin(), list.end(), list1.begin()); +// list1: [ "one", "two", "three" ] -QVector vect2(8); -qCopy(list.begin(), list.end(), vect2.begin() + 2); -// vect: [ "", "", "one", "two", "three", "", "", "" ] +QList list2(8); +qCopy(list.begin(), list.end(), list2.begin() + 2); +// list2: [ "", "", "one", "two", "three", "", "", "" ] //! [4] @@ -119,26 +119,26 @@ qCopy(list.begin(), list.end(), vect2.begin() + 2); QStringList list; list << "one" << "two" << "three"; -QVector vect(5); -qCopyBackward(list.begin(), list.end(), vect.end()); -// vect: [ "", "", "one", "two", "three" ] +QList backList(5); +qCopyBackward(list.begin(), list.end(), backList.end()); +// backList: [ "", "", "one", "two", "three" ] //! [5] //! [6] -QStringList list; -list << "one" << "two" << "three"; +QStringList listLeft; +listLeft << "one" << "two" << "three"; -QVector vect(3); -vect[0] = "one"; -vect[1] = "two"; -vect[2] = "three"; +QList listRight(3); +listRight[0] = "one"; +listRight[1] = "two"; +listRight[2] = "three"; -bool ret1 = qEqual(list.begin(), list.end(), vect.begin()); +bool ret1 = qEqual(listLeft.begin(), listLeft.end(), listRight.begin()); // ret1 == true -vect[2] = "seven"; -bool ret2 = qEqual(list.begin(), list.end(), vect.begin()); +listRight[2] = "seven"; +bool ret2 = qEqual(listLeft.begin(), listLeft.end(), listRight.begin()); // ret2 == false //! [6] @@ -281,19 +281,19 @@ list.insert(i, 12); //! [19] -QVector vect; -vect << 3 << 3 << 6 << 6 << 6 << 8; -QVector::iterator begin6 = - qLowerBound(vect.begin(), vect.end(), 6); -QVector::iterator end6 = - qUpperBound(begin6, vect.end(), 6); +QList list; +list << 3 << 3 << 6 << 6 << 6 << 8; +QList::iterator begin6 = + qLowerBound(list.begin(), list.end(), 6); +QList::iterator end6 = + qUpperBound(begin6, list.end(), 6); -QVector::iterator i = begin6; +QList::iterator i = begin6; while (i != end6) { *i = 7; ++i; } -// vect: [ 3, 3, 7, 7, 7, 8 ] +// list: [ 3, 3, 7, 7, 7, 8 ] //! [19] @@ -312,29 +312,29 @@ list.insert(i, 12); //! [21] -QVector vect; -vect << 3 << 3 << 6 << 6 << 6 << 8; -QVector::iterator begin6 = - qLowerBound(vect.begin(), vect.end(), 6); -QVector::iterator end6 = - qUpperBound(vect.begin(), vect.end(), 6); +QList list; +list << 3 << 3 << 6 << 6 << 6 << 8; +QList::iterator begin6 = + qLowerBound(list.begin(), list.end(), 6); +QList::iterator end6 = + qUpperBound(list.begin(), list.end(), 6); -QVector::iterator i = begin6; +QList::iterator i = begin6; while (i != end6) { *i = 7; ++i; } -// vect: [ 3, 3, 7, 7, 7, 8 ] +// list: [ 3, 3, 7, 7, 7, 8 ] //! [21] //! [22] -QVector vect; -vect << 3 << 3 << 6 << 6 << 6 << 8; +QList list; +list << 3 << 3 << 6 << 6 << 6 << 8; -QVector::iterator i = - qBinaryFind(vect.begin(), vect.end(), 6); -// i == vect.begin() + 2 (or 3 or 4) +QList::iterator i = + qBinaryFind(list.begin(), list.end(), 6); +// i == list.begin() + 2 (or 3 or 4) //! [22] diff --git a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp index 0d0b864a83..265e4a724a 100644 --- a/src/corelib/doc/snippets/code/doc_src_qiterator.cpp +++ b/src/corelib/doc/snippets/code/doc_src_qiterator.cpp @@ -64,23 +64,6 @@ while (i.hasPrevious()) qDebug() << i.previous(); //! [1] -//! [4] -QVector vector; -... -QVectorIterator i(vector); -while (i.hasNext()) - qDebug() << i.next(); -//! [4] - - -//! [5] -QVectorIterator i(vector); -i.toBack(); -while (i.hasPrevious()) - qDebug() << i.previous(); -//! [5] - - //! [6] QSet set; ... @@ -127,35 +110,6 @@ while (i.hasNext()) { } //! [10] -//! [14] -QVector vector; -... -QMutableVectorIterator i(vector); -while (i.hasNext()) - qDebug() << i.next(); -//! [14] - -//! [15] -QMutableVectorIterator i(vector); -i.toBack(); -while (i.hasPrevious()) - qDebug() << i.previous(); -//! [15] - - -//! [16] -QMutableVectorIterator i(vector); -while (i.hasNext()) { - int val = i.next(); - if (val < 0) { - i.setValue(-val); - } else if (val == 0) { - i.remove(); - } -} -//! [16] - - //! [17] QSet set; ... @@ -182,16 +136,6 @@ while (i.hasNext()) { } //! [19] -//! [21] -QMutableVectorIterator i(vector); -while (i.hasNext()) { - int val = i.next(); - if (val < -32768 || val > 32767) - i.remove(); -} -//! [21] - - //! [22] QMutableSetIterator i(set); while (i.hasNext()) { @@ -210,15 +154,6 @@ while (i.hasNext()) { } //! [23] -//! [25] -QMutableVectorIterator i(list); -while (i.hasNext()) { - double val = i.next(); - i.setValue(std::sqrt(val)); -} -//! [25] - - //! [26] QMap map; ... diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp index 0dc47f2370..9f2884667c 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qrandom.cpp @@ -95,9 +95,9 @@ //! [8] //! [9] - QVector vector; - vector.resize(16); - QRandomGenerator::global()->fillRange(vector.data(), vector.size()); + QList list; + list.resize(16); + QRandomGenerator::global()->fillRange(list.data(), list.size()); //! [9] //! [10] diff --git a/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp index 973ae75847..cb6928b129 100644 --- a/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_serialization_qcborstream.cpp @@ -208,7 +208,7 @@ //! [19] //! [20] - void appendList(QCborStreamWriter &writer, const QVector &values) + void appendList(QCborStreamWriter &writer, const QList &values) { writer.startArray(); for (const QString &s : values) @@ -228,7 +228,7 @@ //! [21] //! [22] - void appendMap(QCborStreamWriter &writer, const QVector> &values) + void appendMap(QCborStreamWriter &writer, const QList> &values) { writer.startMap(); for (const auto pair : values) { diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp index cdf1ae0eb1..26b952a77a 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp @@ -49,162 +49,162 @@ ****************************************************************************/ //! [0] -QList integerVector; -QList stringVector; +QList integerList; +QList stringList; //! [0] //! [1] -QList vector(200); +QList list(200); //! [1] //! [2] -QList vector(200, "Pass"); +QList list(200, "Pass"); //! [2] //! [3] -if (vector[0] == "Liz") - vector[0] = "Elizabeth"; +if (list[0] == "Liz") + list[0] = "Elizabeth"; //! [3] //! [4] -for (int i = 0; i < vector.size(); ++i) { - if (vector.at(i) == "Alfonso") +for (int i = 0; i < list.size(); ++i) { + if (list.at(i) == "Alfonso") cout << "Found Alfonso at position " << i << Qt::endl; } //! [4] //! [5] -int i = vector.indexOf("Harumi"); +int i = list.indexOf("Harumi"); if (i != -1) cout << "First occurrence of Harumi is at position " << i << Qt::endl; //! [5] //! [6] -QList vector(10); -int *data = vector.data(); +QList list(10); +int *data = list.data(); for (int i = 0; i < 10; ++i) data[i] = 2 * i; //! [6] //! [7] -QList vector; -vector.append("one"); -vector.append("two"); +QList list; +list.append("one"); +list.append("two"); QString three = "three"; -vector.append(three); -// vector: ["one", "two", "three"] +list.append(three); +// list: ["one", "two", "three"] // three: "three" //! [7] //! [move-append] -QList vector; -vector.append("one"); -vector.append("two"); +QList list; +list.append("one"); +list.append("two"); QString three = "three"; -vector.append(std::move(three)); -// vector: ["one", "two", "three"] +list.append(std::move(three)); +// list: ["one", "two", "three"] // three: "" //! [move-append] //! [emplace] -QList vector{"a", "ccc"}; -vector.emplace(1, 2, 'b'); -// vector: ["a", "bb", "ccc"] +QList list{"a", "ccc"}; +list.emplace(1, 2, 'b'); +// list: ["a", "bb", "ccc"] //! [emplace] //! [emplace-back] -QList vector{"one", "two"}; -vector.emplaceBack(3, 'a'); -qDebug() << vector; -// vector: ["one", "two", "aaa"] +QList list{"one", "two"}; +list.emplaceBack(3, 'a'); +qDebug() << list; +// list: ["one", "two", "aaa"] //! [emplace-back] //! [emplace-back-ref] -QList vector; -auto &ref = vector.emplaceBack(); +QList list; +auto &ref = list.emplaceBack(); ref = "one"; -// vector: ["one"] +// list: ["one"] //! [emplace-back-ref] //! [8] -QList vector; -vector.prepend("one"); -vector.prepend("two"); -vector.prepend("three"); -// vector: ["three", "two", "one"] +QList list; +list.prepend("one"); +list.prepend("two"); +list.prepend("three"); +// list: ["three", "two", "one"] //! [8] //! [9] -QList vector; -vector << "alpha" << "beta" << "delta"; -vector.insert(2, "gamma"); -// vector: ["alpha", "beta", "gamma", "delta"] +QList list; +list << "alpha" << "beta" << "delta"; +list.insert(2, "gamma"); +// list: ["alpha", "beta", "gamma", "delta"] //! [9] //! [10] -QList vector; -vector << 2.718 << 1.442 << 0.4342; -vector.insert(1, 3, 9.9); -// vector: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342] +QList list; +list << 2.718 << 1.442 << 0.4342; +list.insert(1, 3, 9.9); +// list: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342] //! [10] //! [11] -QList vector(3); -vector.fill("Yes"); -// vector: ["Yes", "Yes", "Yes"] +QList list(3); +list.fill("Yes"); +// list: ["Yes", "Yes", "Yes"] -vector.fill("oh", 5); -// vector: ["oh", "oh", "oh", "oh", "oh"] +list.fill("oh", 5); +// list: ["oh", "oh", "oh", "oh", "oh"] //! [11] //! [12] -QList vector; -vector << "A" << "B" << "C" << "B" << "A"; -vector.indexOf("B"); // returns 1 -vector.indexOf("B", 1); // returns 1 -vector.indexOf("B", 2); // returns 3 -vector.indexOf("X"); // returns -1 +QList 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 //! [12] //! [13] -QList vector; -vector << "A" << "B" << "C" << "B" << "A"; -vector.lastIndexOf("B"); // returns 3 -vector.lastIndexOf("B", 3); // returns 3 -vector.lastIndexOf("B", 2); // returns 1 -vector.lastIndexOf("X"); // returns -1 +QList 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 //! [13] //! [16] std::vector stdvector; -vector.push_back(1.2); -vector.push_back(0.5); -vector.push_back(3.14); +stdvector.push_back(1.2); +stdvector.push_back(0.5); +stdvector.push_back(3.14); -QList vector = QList::fromStdVector(stdvector); +QList list = QList::fromStdVector(stdvector); //! [16] //! [17] -QList vector; -vector << 1.2 << 0.5 << 3.14; +QList list; +list << 1.2 << 0.5 << 3.14; -std::vector stdvector = vector.toStdVector(); +std::vector stdlist = list.toStdVector(); //! [17] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp deleted file mode 100644 index 38fa526ef4..0000000000 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QList integerList; -QList dateList; -//! [0] - - -//! [1a] -QList list = { "one", "two", "three" }; -//! [1a] - - -//! [1b] -list << "four" << "five"; -//! [1b] - - -//! [2] -if (list[0] == "Bob") - list[0] = "Robert"; -//! [2] - - -//! [3] -for (int i = 0; i < list.size(); ++i) { - if (list.at(i) == "Jane") - cout << "Found Jane at position " << i << Qt::endl; -} -//! [3] - - -//! [4] -QList list; -... -while (!list.isEmpty()) - delete list.takeFirst(); -//! [4] - - -//! [5] -int i = list.indexOf("Jane"); -if (i != -1) - cout << "First occurrence of Jane is at position " << i << Qt::endl; -//! [5] - - -//! [6] -QList list; -list.append("one"); -list.append("two"); -list.append("three"); -// list: ["one", "two", "three"] -//! [6] - - -//! [7] -QList list; -list.prepend("one"); -list.prepend("two"); -list.prepend("three"); -// list: ["three", "two", "one"] -//! [7] - - -//! [8] -QList list; -list << "alpha" << "beta" << "delta"; -list.insert(2, "gamma"); -// list: ["alpha", "beta", "gamma", "delta"] -//! [8] - - -//! [9] -QList list; -list << "sun" << "cloud" << "sun" << "rain"; -list.removeAll("sun"); -// list: ["cloud", "rain"] -//! [9] - - -//! [10] -QList list; -list << "sun" << "cloud" << "sun" << "rain"; -list.removeOne("sun"); -// list: ["cloud", "sun", "rain"] -//! [10] - - -//! [11] -QList list; -list << "A" << "B" << "C" << "D" << "E" << "F"; -list.move(1, 4); -// list: ["A", "C", "D", "E", "B", "F"] -//! [11] - - -//! [12] -QList list; -list << "A" << "B" << "C" << "D" << "E" << "F"; -list.swapItemsAt(1, 4); -// list: ["A", "E", "C", "D", "B", "F"] -//! [12] - - -//! [13] -QList 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 -//! [13] - - -//! [14] -QList 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 -//! [14] - - -//! [15] -QList list; -list.append("January"); -list.append("February"); -... -list.append("December"); - -QList::iterator i; -for (i = list.begin(); i != list.end(); ++i) - cout << *i << Qt::endl; -//! [15] - - -//! [16] -QList::iterator i; -for (i = list.begin(); i != list.end(); ++i) - *i += 2; -//! [16] - - -//! [17] -QList list; -... -qDeleteAll(list.begin(), list.end()); -//! [17] - - -//! [18] -if (*it == "Hello") - *it = "Bonjour"; -//! [18] - - -//! [19] -QList list; -list.append("January"); -list.append("February"); -... -list.append("December"); - -QList::const_iterator i; -for (i = list.constBegin(); i != list.constEnd(); ++i) - cout << *i << Qt::endl; -//! [19] - - -//! [20] -QList list; -... -qDeleteAll(list.constBegin(), list.constEnd()); -//! [20] - - -//! [21] -QVector vect; -vect << 20.0 << 30.0 << 40.0 << 50.0; - -QList list = QVector::fromVector(vect); -// list: [20.0, 30.0, 40.0, 50.0] -//! [21] - - -//! [22] -QStringList list; -list << "Sven" << "Kim" << "Ola"; - -QVector vect = list.toVector(); -// vect: ["Sven", "Kim", "Ola"] -//! [22] - - -//! [23] -QSet set; -set << 20 << 30 << 40 << ... << 70; - -QList list = QList::fromSet(set); -std::sort(list.begin(), list.end()); -//! [23] - - -//! [24] -QStringList list; -list << "Julia" << "Mike" << "Mike" << "Julia" << "Julia"; - -QSet set = list.toSet(); -set.contains("Julia"); // returns true -set.contains("Mike"); // returns true -set.size(); // returns 2 -//! [24] - - -//! [25] -std::list stdlist; -list.push_back(1.2); -list.push_back(0.5); -list.push_back(3.14); - -QList list = QList::fromStdList(stdlist); -//! [25] - - -//! [26] -QList list; -list << 1.2 << 0.5 << 3.14; - -std::list stdlist = list.toStdList(); -//! [26] diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index d73c9dd07b..5b9b700669 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -42,7 +42,7 @@ The Qt library provides a set of general purpose template-based container classes. These classes can be used to store items of a specified type. For example, if you need a resizable array of - \l{QString}s, use QVector. + \l{QString}s, use QList. These container classes are designed to be lighter, safer, and easier to use than the STL containers. If you are unfamiliar with @@ -74,9 +74,9 @@ \section1 The Container Classes - Qt provides the following sequential containers: QVector, + Qt provides the following sequential containers: QList, QStack, and QQueue. For most - applications, QVector is the best type to use. It provides very fast + applications, QList is the best type to use. It provides very fast appends. If you really need a linked-list, use std::list. QStack and QQueue are convenience classes that provide LIFO and FIFO semantics. @@ -93,30 +93,30 @@ \table \header \li Class \li Summary - \row \li \l{QVector} + \row \li \l{QList} \li This is by far the most commonly used container class. It stores a list of values of a given type (T) that can be accessed by index. Internally, it stores an array of values of a given type at adjacent positions in memory. Inserting at the front or in the middle of - a vector can be quite slow, because it can lead to large numbers + a list can be quite slow, because it can lead to large numbers of items having to be moved by one position in memory. \row \li \l{QVarLengthArray} \li This provides a low-level variable-length array. It can be used - instead of QVector in places where speed is particularly important. + instead of QList in places where speed is particularly important. \row \li \l{QStack} - \li This is a convenience subclass of QVector that provides + \li This is a convenience subclass of QList that provides "last in, first out" (LIFO) semantics. It adds the following - functions to those already present in QVector: + functions to those already present in QList: \l{QStack::push()}{push()}, \l{QStack::pop()}{pop()}, and \l{QStack::top()}{top()}. \row \li \l{QQueue} - \li This is a convenience subclass of QVector that provides + \li This is a convenience subclass of QList that provides "first in, first out" (FIFO) semantics. It adds the following - functions to those already present in QQVector: + functions to those already present in QList: \l{QQueue::enqueue()}{enqueue()}, \l{QQueue::dequeue()}{dequeue()}, and \l{QQueue::head()}{head()}. @@ -147,11 +147,11 @@ \endtable Containers can be nested. For example, it is perfectly possible - to use a QMap>, where the key type is - QString and the value type QVector. + to use a QMap>, where the key type is + QString and the value type QList. The containers are defined in individual header files with the - same name as the container (e.g., \c ). For + same name as the container (e.g., \c ). For convenience, the containers are forward declared in \c . @@ -167,10 +167,10 @@ double, pointer types, and Qt data types such as QString, QDate, and QTime, but it doesn't cover QObject or any QObject subclass (QWidget, QDialog, QTimer, etc.). If you attempt to instantiate a - QVector, the compiler will complain that QWidget's copy + QList, the compiler will complain that QWidget's copy constructor and assignment operators are disabled. If you want to store these kinds of objects in a container, store them as - pointers, for example as QVector. + pointers, for example as QList. Here's an example custom data type that meets the requirement of an assignable data type: @@ -210,7 +210,7 @@ \target default-constructed value The documentation of certain container class functions refer to - \e{default-constructed values}; for example, QVector + \e{default-constructed values}; for example, QList automatically initializes its items with default-constructed values, and QMap::value() returns a default-constructed value if the specified key isn't in the map. For most value types, this @@ -241,22 +241,22 @@ read-write access. \table - \header \li Containers \li Read-only iterator + \header \li Containers \li Read-only iterator \li Read-write iterator \li QMutableListIterator - \row \li QVector, QStack, QQueue \li QVectorIterator - \li QMutableVectorIterator - \row \li QSet \li QSetIterator + \row \li QList, QQueue, QStack, \li QListIterator + \li QMutableListIterator + \row \li QSet \li QSetIterator \li QMutableSetIterator - \row \li QMap, QMultiMap \li QMapIterator + \row \li QMap, QMultiMap \li QMapIterator \li QMutableMapIterator - \row \li QHash, QMultiHash \li QHashIterator + \row \li QHash, QMultiHash \li QHashIterator \li QMutableHashIterator \endtable - In this discussion, we will concentrate on QVector and QMap. The + In this discussion, we will concentrate on QList and QMap. The iterator types for QSet have exactly - the same interface as QVector's iterators; similarly, the iterator + the same interface as QList's iterators; similarly, the iterator types for QHash have the same interface as QMap's iterators. Unlike STL-style iterators (covered \l{STL-style @@ -271,59 +271,59 @@ \image javaiterators1.png Here's a typical loop for iterating through all the elements of a - QVector in order and printing them to the console: + QList in order and printing them to the console: \snippet code/doc_src_containers.cpp 1 - It works as follows: The QVector to iterate over is passed to the - QVectorIterator constructor. At that point, the iterator is located + It works as follows: The QList to iterate over is passed to the + QListIterator constructor. At that point, the iterator is located just in front of the first item in the list (before item "A"). - Then we call \l{QVectorIterator::hasNext()}{hasNext()} to + Then we call \l{QListIterator::hasNext()}{hasNext()} to check whether there is an item after the iterator. If there is, we - call \l{QVectorIterator::next()}{next()} to jump over that + call \l{QListIterator::next()}{next()} to jump over that item. The next() function returns the item that it jumps over. For - a QVector, that item is of type QString. + a QList, that item is of type QString. - Here's how to iterate backward in a QVector: + Here's how to iterate backward in a QList: \snippet code/doc_src_containers.cpp 2 The code is symmetric with iterating forward, except that we - start by calling \l{QVectorIterator::toBack()}{toBack()} + start by calling \l{QListIterator::toBack()}{toBack()} to move the iterator after the last item in the list. The diagram below illustrates the effect of calling - \l{QVectorIterator::next()}{next()} and - \l{QVectorIterator::previous()}{previous()} on an iterator: + \l{QListIterator::next()}{next()} and + \l{QListIterator::previous()}{previous()} on an iterator: \image javaiterators2.png - The following table summarizes the QVectorIterator API: + The following table summarizes the QListIterator API: \table \header \li Function \li Behavior - \row \li \l{QVectorIterator::toFront()}{toFront()} + \row \li \l{QListIterator::toFront()}{toFront()} \li Moves the iterator to the front of the list (before the first item) - \row \li \l{QVectorIterator::toBack()}{toBack()} + \row \li \l{QListIterator::toBack()}{toBack()} \li Moves the iterator to the back of the list (after the last item) - \row \li \l{QVectorIterator::hasNext()}{hasNext()} + \row \li \l{QListIterator::hasNext()}{hasNext()} \li Returns \c true if the iterator isn't at the back of the list - \row \li \l{QVectorIterator::next()}{next()} + \row \li \l{QListIterator::next()}{next()} \li Returns the next item and advances the iterator by one position - \row \li \l{QVectorIterator::peekNext()}{peekNext()} + \row \li \l{QListIterator::peekNext()}{peekNext()} \li Returns the next item without moving the iterator - \row \li \l{QVectorIterator::hasPrevious()}{hasPrevious()} + \row \li \l{QListIterator::hasPrevious()}{hasPrevious()} \li Returns \c true if the iterator isn't at the front of the list - \row \li \l{QVectorIterator::previous()}{previous()} + \row \li \l{QListIterator::previous()}{previous()} \li Returns the previous item and moves the iterator back by one position - \row \li \l{QVectorIterator::peekPrevious()}{peekPrevious()} + \row \li \l{QListIterator::peekPrevious()}{peekPrevious()} \li Returns the previous item without moving the iterator \endtable - QVectorIterator provides no functions to insert or remove items + QListIterator provides no functions to insert or remove items from the list as we iterate. To accomplish this, you must use QMutableListIterator. Here's an example where we remove all - odd numbers from a QVector using QMutableListIterator: + odd numbers from a QList using QMutableListIterator: \snippet code/doc_src_containers.cpp 3 @@ -357,11 +357,11 @@ \snippet code/doc_src_containers.cpp 6 As mentioned above QSet's iterator - classes have exactly the same API as QVector's. We will now turn to + classes have exactly the same API as QList's. We will now turn to QMapIterator, which is somewhat different because it iterates on (key, value) pairs. - Like QVectorIterator, QMapIterator provides + Like QListIterator, QMapIterator provides \l{QMapIterator::toFront()}{toFront()}, \l{QMapIterator::toBack()}{toBack()}, \l{QMapIterator::hasNext()}{hasNext()}, @@ -407,48 +407,48 @@ possible because they are faster than read-write iterators. \table - \header \li Containers \li Read-only iterator + \header \li Containers \li Read-only iterator \li Read-write iterator - \row \li QVector, QStack, QQueue \li QVector::const_iterator - \li QVector::iterator - \row \li QSet \li QSet::const_iterator + \row \li QList, QStack, QQueue \li QList::const_iterator + \li QList::iterator + \row \li QSet \li QSet::const_iterator \li QSet::iterator - \row \li QMap, QMultiMap \li QMap::const_iterator + \row \li QMap, QMultiMap \li QMap::const_iterator \li QMap::iterator - \row \li QHash, QMultiHash \li QHash::const_iterator + \row \li QHash, QMultiHash \li QHash::const_iterator \li QHash::iterator \endtable The API of the STL iterators is modelled on pointers in an array. For example, the \c ++ operator advances the iterator to the next item, and the \c * operator returns the item that the iterator - points to. In fact, for QVector and QStack, which store their + points to. In fact, for QList and QStack, which store their items at adjacent memory positions, the - \l{QVector::iterator}{iterator} type is just a typedef for \c{T *}, - and the \l{QVector::iterator}{const_iterator} type is + \l{QList::iterator}{iterator} type is just a typedef for \c{T *}, + and the \l{QList::iterator}{const_iterator} type is just a typedef for \c{const T *}. - In this discussion, we will concentrate on QVector and QMap. The + In this discussion, we will concentrate on QList and QMap. The iterator types for QSet have exactly - the same interface as QVector's iterators; similarly, the iterator + the same interface as QList's iterators; similarly, the iterator types for QHash have the same interface as QMap's iterators. Here's a typical loop for iterating through all the elements of a - QVector in order and converting them to lowercase: + QList in order and converting them to lowercase: \snippet code/doc_src_containers.cpp 10 Unlike \l{Java-style iterators}, STL-style iterators point - directly at items. The \l{QVector::begin()}{begin()} function of a container returns an + directly at items. The \l{QList::begin()}{begin()} function of a container returns an iterator that points to the first item in the container. The - \l{QVector::end()}{end()} function of a container returns an iterator to the + \l{QList::end()}{end()} function of a container returns an iterator to the imaginary item one position past the last item in the container. - \l {QVector::end()}{end()} marks an invalid position; it must never be dereferenced. + \l {QList::end()}{end()} marks an invalid position; it must never be dereferenced. It is typically used in a loop's break condition. If the list is - empty, \l{QVector::begin}{begin()} equals \l{QVector::end()}{end()}, so we never execute the loop. + empty, \l{QList::begin}{begin()} equals \l{QList::end()}{end()}, so we never execute the loop. The diagram below shows the valid iterator positions as red - arrows for a vector containing four items: + arrows for a list containing four items: \image stliterators1.png @@ -462,8 +462,8 @@ compilers also allow us to write \c{i->toLower()}, but some don't. - For read-only access, you can use const_iterator, \l{QVector::constBegin}{constBegin()}, - and \l{QVector::constEnd()}{constEnd()}. For example: + For read-only access, you can use const_iterator, \l{QList::constBegin}{constBegin()}, + and \l{QList::constEnd()}{constEnd()}. For example: \snippet code/doc_src_containers.cpp 12 @@ -501,7 +501,7 @@ Thanks to \l{implicit sharing}, it is very inexpensive for a function to return a container per value. The Qt API contains - dozens of functions that return a QVector or QStringList per value + dozens of functions that return a QList or QStringList per value (e.g., QSplitter::sizes()). If you want to iterate over these using an STL iterator, you should always take a copy of the container and iterate over the copy. For example: @@ -521,7 +521,7 @@ \snippet code/doc_src_containers.cpp 24 - The above example only shows a problem with QVector, but + The above example only shows a problem with QList, but the problem exists for all the implicitly shared Qt containers. \target foreach @@ -534,7 +534,7 @@ Its syntax is: \c foreach (\e variable, \e container) \e statement. For example, here's how to use \c foreach to iterate - over a QVector: + over a QList: \snippet code/doc_src_containers.cpp 15 @@ -620,8 +620,8 @@ example, inserting an item in the middle of a std::list is an extremely fast operation, irrespective of the number of items stored in the list. On the other hand, inserting an item - in the middle of a QVector is potentially very expensive if the - QVector contains many items, since half of the items must be + in the middle of a QList is potentially very expensive if the + QList contains many items, since half of the items must be moved one position in memory. To describe algorithmic complexity, we use the following @@ -637,7 +637,7 @@ \li \b{Constant time:} O(1). A function is said to run in constant time if it requires the same amount of time no matter how many items are present in the container. One example is - QVector::push_back(). + QList::push_back(). \li \b{Logarithmic time:} O(log \e n). A function that runs in logarithmic time is a function whose running time is @@ -647,7 +647,7 @@ \li \b{Linear time:} O(\e n). A function that runs in linear time will execute in a time directly proportional to the number of items stored in the container. One example is - QVector::insert(). + QList::insert(). \li \b{Linear-logarithmic time:} O(\e{n} log \e n). A function that runs in linear-logarithmic time is asymptotically slower @@ -660,11 +660,11 @@ \endlist The following table summarizes the algorithmic complexity of the sequential - container QVector: + container QList: \table - \header \li \li Index lookup \li Insertion \li Prepending \li Appending - \row \li QVector \li O(1) \li O(n) \li O(n) \li Amort. O(1) + \header \li \li Index lookup \li Insertion \li Prepending \li Appending + \row \li QList \li O(1) \li O(n) \li O(n) \li Amort. O(1) \endtable In the table, "Amort." stands for "amortized behavior". For @@ -685,15 +685,15 @@ \row \li QSet \li Amort. O(1) \li O(\e n) \li Amort. O(1) \li O(\e n) \endtable - With QVector, QHash, and QSet, the performance of appending items + With QList, QHash, and QSet, the performance of appending items is amortized O(log \e n). It can be brought down to O(1) by - calling QVector::reserve(), QHash::reserve(), or QSet::reserve() + calling QList::reserve(), QHash::reserve(), or QSet::reserve() with the expected number of items before you insert the items. The next section discusses this topic in more depth. \section1 Growth Strategies - QVector, QString, and QByteArray store their items + QList, QString, and QByteArray store their items contiguously in memory; QHash keeps a hash table whose size is proportional to the number of items in the hash. To avoid reallocating the data every single @@ -732,12 +732,12 @@ QByteArray uses more or less the same algorithm as QString. - QVector also uses that algorithm for data types that can be + QList also uses that algorithm for data types that can be moved around in memory using \c memcpy() (including the basic C++ types, the pointer types, and Qt's \l{shared classes}) but uses a different algorithm for data types that can only be moved by calling the copy constructor and a destructor. Since the cost of - reallocating is higher in that case, QVector reduces the + reallocating is higher in that case, QList reduces the number of reallocations by always doubling the memory when running out of space. @@ -748,7 +748,7 @@ QSet and QCache as well. For most applications, the default growing algorithm provided by - Qt does the trick. If you need more control, QVector, + Qt does the trick. If you need more control, QList, QHash, QSet, QString, and QByteArray provide a trio of functions that allow you to check and specify how much memory to use to store the items: diff --git a/src/corelib/doc/src/datastreamformat.qdoc b/src/corelib/doc/src/datastreamformat.qdoc index 1e23b19c1f..303d374678 100644 --- a/src/corelib/doc/src/datastreamformat.qdoc +++ b/src/corelib/doc/src/datastreamformat.qdoc @@ -66,6 +66,7 @@ \li QIcon \li QImage \li QKeySequence + \li QList \li QMap \li QMargins \li QMatrix4x4 @@ -88,7 +89,6 @@ \li QVector2D \li QVector3D \li QVector4D - \li QVector \endlist \sa {JSON Support in Qt} diff --git a/src/corelib/doc/src/implicit-sharing.qdoc b/src/corelib/doc/src/implicit-sharing.qdoc index 03cbdd7ff0..d789f8bf92 100644 --- a/src/corelib/doc/src/implicit-sharing.qdoc +++ b/src/corelib/doc/src/implicit-sharing.qdoc @@ -139,7 +139,7 @@ is called for \c p2, because painting a pixmap will modify it. \warning Be careful with copying an implicitly shared container - (QMap, QVector, etc.) while you use + (QMap, QList, etc.) while you use \l{STL-style iterators}{STL-style iterator}. See \l{Implicit sharing iterator problem}. \target implicitly shared classes diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 99b8a8320a..1ff481762c 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -811,7 +811,7 @@ inline QRandomGenerator::SystemGenerator &QRandomGenerator::SystemGenerator::sel efficient way to obtain more than one quantity at a time, as it reduces the number of calls into the Random Number Generator source. - For example, to fill a vector of 16 entries with random values, one may + For example, to fill a list of 16 entries with random values, one may write: \snippet code/src_corelib_global_qrandom.cpp 9 diff --git a/src/corelib/serialization/qcborstreamwriter.cpp b/src/corelib/serialization/qcborstreamwriter.cpp index 791f8775ff..4d6f323e9a 100644 --- a/src/corelib/serialization/qcborstreamwriter.cpp +++ b/src/corelib/serialization/qcborstreamwriter.cpp @@ -729,7 +729,7 @@ void QCborStreamWriter::appendTextString(const char *utf8, qsizetype len) length is implied by the elements contained in it. Note, however, that use of indeterminate-length arrays is not compliant with canonical CBOR encoding. - The following example appends elements from the vector of strings + The following example appends elements from the list of strings passed as input: \snippet code/src_corelib_serialization_qcborstream.cpp 20 @@ -802,7 +802,7 @@ bool QCborStreamWriter::endArray() indeterminate-length maps is not compliant with canonical CBOR encoding (canonical encoding also requires keys to be unique and in sorted order). - The following example appends elements from the vector of int and + The following example appends elements from the list of int and string pairs passed as input: \snippet code/src_corelib_serialization_qcborstream.cpp 22 diff --git a/src/corelib/tools/qiterator.qdoc b/src/corelib/tools/qiterator.qdoc index 9efc1bb48a..174837ad08 100644 --- a/src/corelib/tools/qiterator.qdoc +++ b/src/corelib/tools/qiterator.qdoc @@ -172,9 +172,9 @@ making it possible to access, modify, and remove items without using iterators. - QListIterator\ allows you to iterate over a QList\ (or a - QQueue\). If you want to modify the list as you iterate over - it, use QMutableListIterator\ instead. + QListIterator\ allows you to iterate over a QList\, + a QQueue\ or a QStack\. If you want to modify the list + as you iterate over it, use QMutableListIterator\ instead. The QListIterator constructor takes a QList as argument. After construction, the iterator is located at the very beginning of @@ -212,53 +212,9 @@ /*! \class QVectorIterator \inmodule QtCore - \brief The QVectorIterator class provides a Java-style const iterator for QVector and QStack. + \brief QVectorIterator is an alias for QListIterator. - QVector has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - An alternative to using iterators is to use index positions. Most - QVector member functions take an index as their first parameter, - making it possible to access, insert, and remove items without - using iterators. - - QVectorIterator\ allows you to iterate over a QVector\ - (or a QStack\). If you want to modify the vector as you - iterate over it, use QMutableVectorIterator\ instead. - - The QVectorIterator constructor takes a QVector as argument. - After construction, the iterator is located at the very beginning - of the vector (before the first item). Here's how to iterate over - all the elements sequentially: - - \snippet code/doc_src_qiterator.cpp 4 - - The next() function returns the next item in the vector and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \image javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet code/doc_src_qiterator.cpp 5 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - Multiple iterators can be used on the same vector. If the vector - is modified while a QVectorIterator is active, the QVectorIterator - will continue iterating over the original vector, ignoring the - modified copy. - - \sa QMutableVectorIterator, QVector::const_iterator + Please see the QListIterator documentation for details. */ /*! @@ -312,7 +268,7 @@ \class QMutableListIterator \inmodule QtCore - \brief The QMutableListIterator class provides a Java-style non-const iterator for QList and QQueue. + \brief The QMutableListIterator class provides a Java-style non-const iterator for QList, QQueue and QStack. QList has both \l{Java-style iterators} and \l{STL-style iterators}. The Java-style iterators are more high-level and @@ -377,67 +333,9 @@ /*! \class QMutableVectorIterator \inmodule QtCore + \brief QMutableVectorIterator is an alias for QMutableListIterator. - \brief The QMutableVectorIterator class provides a Java-style non-const iterator for QVector and QStack. - - QVector has both \l{Java-style iterators} and \l{STL-style - iterators}. The Java-style iterators are more high-level and - easier to use than the STL-style iterators; on the other hand, - they are slightly less efficient. - - An alternative to using iterators is to use index positions. Most - QVector member functions take an index as their first parameter, - making it possible to access, insert, and remove items without - using iterators. - - QMutableVectorIterator\ allows you to iterate over a - QVector\ and modify the vector. If you don't want to modify - the vector (or have a const QVector), use the slightly faster - QVectorIterator\ instead. - - The QMutableVectorIterator constructor takes a QVector as - argument. After construction, the iterator is located at the very - beginning of the list (before the first item). Here's how to - iterate over all the elements sequentially: - - \snippet code/doc_src_qiterator.cpp 14 - - The next() function returns the next item in the vector and - advances the iterator. Unlike STL-style iterators, Java-style - iterators point \e between items rather than directly \e at - items. The first call to next() advances the iterator to the - position between the first and second item, and returns the first - item; the second call to next() advances the iterator to the - position between the second and third item, returning the second - item; and so on. - - \image javaiterators1.png - - Here's how to iterate over the elements in reverse order: - - \snippet code/doc_src_qiterator.cpp 15 - - If you want to find all occurrences of a particular value, use - findNext() or findPrevious() in a loop. - - If you want to remove items as you iterate over the vector, use - remove(). If you want to modify the value of an item, use - setValue(). If you want to insert a new item in the vector, use - insert(). - - Example: - \snippet code/doc_src_qiterator.cpp 16 - - The example traverses a vector, replacing negative numbers with - their absolute values, and eliminating zeroes. - - Only one mutable iterator can be active on a given vector at any - time. Furthermore, no changes should be done directly to the - vector while the iterator is active (as opposed to through the - iterator), since this could invalidate the iterator and lead to - undefined behavior. - - \sa QVectorIterator, QVector::iterator + Please see the QMutableListIterator documentation for details. */ /*! @@ -501,16 +399,6 @@ \sa operator=() */ -/*! - \fn template QVectorIterator::QVectorIterator(const QVector &vector) - \fn template QMutableVectorIterator::QMutableVectorIterator(QVector &vector) - - Constructs an iterator for traversing \a vector. The iterator is - set to be at the front of the vector (before the first item). - - \sa operator=() -*/ - /*! \fn template QSetIterator::QSetIterator(const QSet &set) \fn template QMutableSetIterator::QMutableSetIterator(QSet &set) @@ -530,15 +418,6 @@ \sa toFront(), toBack() */ -/*! \fn template QVectorIterator &QVectorIterator::operator=(const QVector &vector) - \fn template QMutableVectorIterator &QMutableVectorIterator::operator=(QVector &vector) - - Makes the iterator operate on \a vector. The iterator is set to be - at the front of the vector (before the first item). - - \sa toFront(), toBack() -*/ - /*! \fn template QSetIterator &QSetIterator::operator=(const QSet &set) \fn template QMutableSetIterator &QMutableSetIterator::operator=(QSet &set) @@ -549,10 +428,8 @@ */ /*! \fn template void QListIterator::toFront() - \fn template void QVectorIterator::toFront() \fn template void QSetIterator::toFront() \fn template void QMutableListIterator::toFront() - \fn template void QMutableVectorIterator::toFront() \fn template void QMutableSetIterator::toFront() Moves the iterator to the front of the container (before the @@ -562,10 +439,8 @@ */ /*! \fn template void QListIterator::toBack() - \fn template void QVectorIterator::toBack() \fn template void QSetIterator::toBack() \fn template void QMutableListIterator::toBack() - \fn template void QMutableVectorIterator::toBack() \fn template void QMutableSetIterator::toBack() Moves the iterator to the back of the container (after the last @@ -575,10 +450,8 @@ */ /*! \fn template bool QListIterator::hasNext() const - \fn template bool QVectorIterator::hasNext() const \fn template bool QSetIterator::hasNext() const \fn template bool QMutableListIterator::hasNext() const - \fn template bool QMutableVectorIterator::hasNext() const \fn template bool QMutableSetIterator::hasNext() const Returns \c true if there is at least one item ahead of the iterator, @@ -589,7 +462,6 @@ */ /*! \fn template const T &QListIterator::next() - \fn template const T &QVectorIterator::next() \fn template const T &QSetIterator::next() \fn template const T &QMutableSetIterator::next() @@ -602,7 +474,6 @@ */ /*! \fn template T &QMutableListIterator::next() - \fn template T &QMutableVectorIterator::next() Returns a reference to the next item, and advances the iterator by one position. @@ -614,7 +485,6 @@ */ /*! \fn template const T &QListIterator::peekNext() const - \fn template const T &QVectorIterator::peekNext() const \fn template const T &QSetIterator::peekNext() const \fn template const T &QMutableSetIterator::peekNext() const @@ -627,7 +497,6 @@ */ /*! \fn template T &QMutableListIterator::peekNext() const - \fn template T &QMutableVectorIterator::peekNext() const Returns a reference to the next item, without moving the iterator. @@ -649,10 +518,8 @@ */ /*! \fn template bool QListIterator::hasPrevious() const - \fn template bool QVectorIterator::hasPrevious() const \fn template bool QSetIterator::hasPrevious() const \fn template bool QMutableListIterator::hasPrevious() const - \fn template bool QMutableVectorIterator::hasPrevious() const Returns \c true if there is at least one item behind the iterator, i.e. the iterator is \e not at the front of the container; @@ -675,7 +542,6 @@ */ /*! \fn template const T &QListIterator::previous() - \fn template const T &QVectorIterator::previous() \fn template const T &QSetIterator::previous() Returns the previous item and moves the iterator back by one @@ -688,7 +554,6 @@ */ /*! \fn template T &QMutableListIterator::previous() - \fn template T &QMutableVectorIterator::previous() Returns a reference to the previous item and moves the iterator back by one position. @@ -712,7 +577,6 @@ */ /*! \fn template const T &QListIterator::peekPrevious() const - \fn template const T &QVectorIterator::peekPrevious() const \fn template const T &QSetIterator::peekPrevious() const Returns the previous item without moving the iterator. @@ -724,7 +588,6 @@ */ /*! \fn template T &QMutableListIterator::peekPrevious() const - \fn template T &QMutableVectorIterator::peekPrevious() const Returns a reference to the previous item, without moving the iterator. @@ -749,10 +612,8 @@ */ /*! \fn template bool QListIterator::findNext(const T &value) - \fn template bool QVectorIterator::findNext(const T &value) \fn template bool QSetIterator::findNext(const T &value) \fn template bool QMutableListIterator::findNext(const T &value) - \fn template bool QMutableVectorIterator::findNext(const T &value) Searches for \a value starting from the current iterator position forward. Returns \c true if \a value is found; otherwise returns \c false. @@ -765,10 +626,8 @@ */ /*! \fn template bool QListIterator::findPrevious(const T &value) - \fn template bool QVectorIterator::findPrevious(const T &value) \fn template bool QSetIterator::findPrevious(const T &value) \fn template bool QMutableListIterator::findPrevious(const T &value) - \fn template bool QMutableVectorIterator::findPrevious(const T &value) \fn template bool QMutableSetIterator::findPrevious(const T &value) Searches for \a value starting from the current iterator position @@ -793,17 +652,6 @@ \sa insert(), setValue() */ -/*! \fn template void QMutableVectorIterator::remove() - - Removes the last item that was jumped over using one of the - traversal functions (next(), previous(), findNext(), findPrevious()). - - Example: - \snippet code/doc_src_qiterator.cpp 21 - - \sa insert(), setValue() -*/ - /*! \fn template void QMutableSetIterator::remove() Removes the last item that was jumped over using one of the @@ -829,22 +677,7 @@ \sa value(), remove(), insert() */ -/*! \fn template void QMutableVectorIterator::setValue(const T &value) const - - Replaces the value of the last item that was jumped over using - one of the traversal functions with \a value. - - The traversal functions are next(), previous(), findNext(), and - findPrevious(). - - Example: - \snippet code/doc_src_qiterator.cpp 25 - - \sa value(), remove(), insert() -*/ - /*! \fn template const T &QMutableListIterator::value() const - \fn template const T &QMutableVectorIterator::value() const \fn template const T &QMutableSetIterator::value() const Returns the value of the last item that was jumped over using one @@ -858,7 +691,6 @@ /*! \fn template T &QMutableListIterator::value() - \fn template T &QMutableVectorIterator::value() \overload Returns a non-const reference to the value of the last item that @@ -866,7 +698,6 @@ */ /*! \fn template void QMutableListIterator::insert(const T &value) - \fn template void QMutableVectorIterator::insert(const T &value) Inserts \a value at the current iterator position. After the call, the iterator is located just after the inserted item. diff --git a/src/corelib/tools/qlist.qdoc b/src/corelib/tools/qlist.qdoc index c0af194858..1a94bf4315 100644 --- a/src/corelib/tools/qlist.qdoc +++ b/src/corelib/tools/qlist.qdoc @@ -74,7 +74,7 @@ \snippet code/src_corelib_tools_qlist.cpp 0 - QList stores its items in a vector (array). Typically, vectors + QList stores its items in an array of continuous memory. Typically, lists are created with an initial size. For example, the following code constructs a QList with 200 elements: @@ -82,17 +82,17 @@ The elements are automatically initialized with a \l{default-constructed value}. If you want to initialize the - vector with a different value, pass that value as the second + list with a different value, pass that value as the second argument to the constructor: \snippet code/src_corelib_tools_qlist.cpp 2 - You can also call fill() at any time to fill the vector with a + You can also call fill() at any time to fill the list with a value. QList uses 0-based indexes, just like C++ arrays. To access the item at a particular index position, you can use operator[](). On - non-const vectors, operator[]() returns a reference to the item + non-const lists, operator[]() returns a reference to the item that can be used on the left side of an assignment: \snippet code/src_corelib_tools_qlist.cpp 3 @@ -106,34 +106,34 @@ Another way to access the data stored in a QList is to call data(). The function returns a pointer to the first item in the - vector. You can use the pointer to directly access and modify the - elements stored in the vector. The pointer is also useful if you + list. You can use the pointer to directly access and modify the + elements stored in the list. The pointer is also useful if you need to pass a QList to a function that accepts a plain C++ array. If you want to find all occurrences of a particular value in a - vector, use indexOf() or lastIndexOf(). The former searches + list, use indexOf() or lastIndexOf(). The former searches forward starting from a given index position, the latter searches backward. Both return the index of the matching item if they found one; otherwise, they return -1. For example: \snippet code/src_corelib_tools_qlist.cpp 5 - If you simply want to check whether a vector contains a + If you simply want to check whether a list contains a particular value, use contains(). If you want to find out how - many times a particular value occurs in the vector, use count(). + many times a particular value occurs in the list, use count(). QList provides these basic functions to add, move, and remove items: insert(), replace(), remove(), prepend(), append(). With the exception of append() and replace(), these functions can be slow - (\l{linear time}) for large vectors, because they require moving many - items in the vector by one position in memory. If you want a container + (\l{linear time}) for large lists, because they require moving many + items in the list by one position in memory. If you want a container class that provides fast insertion/removal in the middle, use std::list instead. Unlike plain C++ arrays, QLists can be resized at any time by calling resize(). If the new size is larger than the old size, - QList might need to reallocate the whole vector. QList tries + QList might need to reallocate the whole list. QList tries to reduce the number of reallocations by preallocating up to twice as much memory as the actual data needs. @@ -155,7 +155,7 @@ per-function basis. Like the other container classes, QList provides \l{Java-style - iterators} (QListIterator and QMutableVectorIterator) and + iterators} (QListIterator and QMutableListIterator) and \l{STL-style iterators} (QList::const_iterator and QList::iterator). In practice, these are rarely used, because you can use indexes into the QList. @@ -195,7 +195,7 @@ /*! \fn template QList QList::mid(int pos, int length = -1) const - Returns a sub-vector which contains elements from this vector, + Returns a sub-list which contains elements from this list, starting at position \a pos. If \a length is -1 (the default), all elements after \a pos are included; otherwise \a length elements (or all remaining elements if there are less than \a length elements) @@ -205,7 +205,7 @@ /*! \fn template QList::QList() - Constructs an empty vector. + Constructs an empty list. \sa resize() */ @@ -221,7 +221,7 @@ /*! \fn template QList::QList(int size) - Constructs a vector with an initial size of \a size elements. + Constructs a list with an initial size of \a size elements. The elements are initialized with a \l{default-constructed value}. @@ -231,7 +231,7 @@ /*! \fn template QList::QList(int size, const T &value) - Constructs a vector with an initial size of \a size elements. + Constructs a list with an initial size of \a size elements. Each element is initialized with \a value. \sa resize(), fill() @@ -253,7 +253,7 @@ /*! \fn template QList::QList(std::initializer_list args) \since 4.8 - Constructs a vector from the std::initializer_list given by \a args. + Constructs a list from the std::initializer_list given by \a args. This constructor is only enabled if the compiler supports C++11 initializer lists. @@ -262,7 +262,7 @@ /*! \fn template template QList::QList(InputIterator first, InputIterator last) \since 5.14 - Constructs a vector with the contents in the iterator range [\a first, \a last). + Constructs a list with the contents in the iterator range [\a first, \a last). The value type of \c InputIterator must be convertible to \c T. */ @@ -279,8 +279,8 @@ /*! \fn template QList &QList::operator=(const QList &other) - Assigns \a other to this vector and returns a reference to this - vector. + Assigns \a other to this list and returns a reference to this + list. */ /*! @@ -305,7 +305,7 @@ /*! \fn template void QList::swap(QList &other) \since 4.8 - Swaps vector \a other with this vector. This operation is very fast and + Swaps list \a other with this list. This operation is very fast and never fails. */ @@ -321,10 +321,10 @@ /*! \fn template bool QList::operator==(const QList &other) const - Returns \c true if \a other is equal to this vector; otherwise + Returns \c true if \a other is equal to this list; otherwise returns \c false. - Two vectors are considered equal if they contain the same values + 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 @@ -335,10 +335,10 @@ /*! \fn template bool QList::operator!=(const QList &other) const - Returns \c true if \a other is not equal to this vector; otherwise + Returns \c true if \a other is not equal to this list; otherwise returns \c false. - Two vectors are considered equal if they contain the same values + 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 @@ -351,7 +351,7 @@ \since 5.6 \relates QList - Returns \c true if vector \a lhs is + Returns \c true if list \a lhs is \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} {lexicographically less than} \a rhs; otherwise returns \c false. @@ -363,7 +363,7 @@ \since 5.6 \relates QList - Returns \c true if vector \a lhs is + Returns \c true if list \a lhs is \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} {lexicographically less than or equal to} \a rhs; otherwise returns \c false. @@ -375,7 +375,7 @@ \since 5.6 \relates QList - Returns \c true if vector \a lhs is + Returns \c true if list \a lhs is \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} {lexicographically greater than} \a rhs; otherwise returns \c false. @@ -387,7 +387,7 @@ \since 5.6 \relates QList - Returns \c true if vector \a lhs is + Returns \c true if list \a lhs is \l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare} {lexicographically greater than or equal to} \a rhs; otherwise returns \c false. @@ -408,21 +408,21 @@ /*! \fn template int QList::size() const - Returns the number of items in the vector. + Returns the number of items in the list. \sa isEmpty(), resize() */ /*! \fn template bool QList::isEmpty() const - Returns \c true if the vector has size 0; otherwise returns \c false. + Returns \c true if the list has size 0; otherwise returns \c false. \sa size(), resize() */ /*! \fn template void QList::resize(int size) - Sets the size of the vector to \a size. If \a size is greater than the + Sets the size of the list to \a size. If \a size is greater than the current size, elements are added to the end; the new elements are initialized with a \l{default-constructed value}. If \a size is less than the current size, elements are removed from the end. @@ -436,14 +436,14 @@ /*! \fn template int QList::capacity() const Returns the maximum number of items that can be stored in the - vector without forcing a reallocation. + list without forcing a reallocation. The sole purpose of this function is to provide a means of fine tuning QList's memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are - in the vector, call size(). + in the list, call size(). - \note a statically allocated vector will report a capacity of 0, + \note a statically allocated list will report a capacity of 0, even if it's not empty. \sa reserve(), squeeze() @@ -452,7 +452,7 @@ /*! \fn template void QList::reserve(int size) Attempts to allocate memory for at least \a size elements. If you - know in advance how large the vector will be, you should call this + know in advance how large the list will be, you should call this function to prevent reallocations and memory fragmentation. If \a size is an underestimate, the worst that will happen is that @@ -507,16 +507,16 @@ /*! \fn template T *QList::data() - Returns a pointer to the data stored in the vector. The pointer - can be used to access and modify the items in the vector. + Returns a pointer to the data stored in the list. The pointer + can be used to access and modify the items in the list. Example: \snippet code/src_corelib_tools_qlist.cpp 6 - The pointer remains valid as long as the vector isn't + The pointer remains valid as long as the list isn't reallocated. - This function is mostly useful to pass a vector to a function + This function is mostly useful to pass a list to a function that accepts a plain C++ array. \sa constData(), operator[]() @@ -529,12 +529,12 @@ /*! \fn template const T *QList::constData() const - Returns a const pointer to the data stored in the vector. The - pointer can be used to access the items in the vector. - The pointer remains valid as long as the vector isn't + Returns a const pointer to the data stored in the list. The + pointer can be used to access the items in the list. + The pointer remains valid as long as the list isn't reallocated. - This function is mostly useful to pass a vector to a function + This function is mostly useful to pass a list to a function that accepts a plain C++ array. \sa data(), operator[]() @@ -542,11 +542,11 @@ /*! \fn template void QList::clear() - Removes all the elements from the vector. + Removes all the elements from the list. \note Until Qt 5.6, this also released the memory used by - the vector. From Qt 5.7, the capacity is preserved. To shed - all capacity, swap with a default-constructed vector: + the list. From Qt 5.7, the capacity is preserved. To shed + all capacity, swap with a default-constructed list: \code QList v ...; QList().swap(v); @@ -559,9 +559,9 @@ /*! \fn template const T &QList::at(int i) const - Returns the item at index position \a i in the vector. + Returns the item at index position \a i in the list. - \a i must be a valid index position in the vector (i.e., 0 <= \a + \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). \sa value(), operator[]() @@ -571,7 +571,7 @@ Returns the item at index position \a i as a modifiable reference. - \a i must be a valid index position in the vector (i.e., 0 <= \a i + \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). Note that using non-const operators can cause QList to do a deep @@ -590,17 +590,17 @@ /*! \fn template void QList::append(const T &value) - Inserts \a value at the end of the vector. + Inserts \a value at the end of the list. Example: \snippet code/src_corelib_tools_qlist.cpp 7 This is the same as calling resize(size() + 1) and assigning \a - value to the new last element in the vector. + value to the new last element in the list. This operation is relatively fast, because QList typically allocates more memory than necessary, so it can grow without - reallocating the entire vector each time. + reallocating the entire list each time. \sa operator<<(), prepend(), insert() */ @@ -621,7 +621,7 @@ \since 5.5 - Appends the items of the \a value vector to this vector. + Appends the items of the \a value list to this list. \sa operator<<(), operator+=() */ @@ -631,15 +631,15 @@ \fn template void QList::prepend(const T &value) \fn template void QList::prepend(T &&value) - Inserts \a value at the beginning of the vector. + Inserts \a value at the beginning of the list. Example: \snippet code/src_corelib_tools_qlist.cpp 8 - This is the same as vector.insert(0, \a value). + This is the same as list.insert(0, \a value). - For large vectors, this operation can be slow (\l{linear time}), - because it requires moving all the items in the vector by one + For large lists, this operation can be slow (\l{linear time}), + because it requires moving all the items in the list by one position further in memory. If you want a container class that provides a fast prepend operation, use std::list instead. @@ -664,7 +664,7 @@ returned reference: \snippet code/src_corelib_tools_qlist.cpp emplace-back-ref - This is the same as vector.emplace(vector.size(), \a args). + This is the same as list.emplace(list.size(), \a args). \sa emplace */ @@ -672,14 +672,14 @@ /*! \fn template void QList::insert(int i, const T &value) \fn template void QList::insert(int i, T &&value) - Inserts \a value at index position \a i in the vector. If \a i is - 0, the value is prepended to the vector. If \a i is size(), the - value is appended to the vector. + 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: \snippet code/src_corelib_tools_qlist.cpp 9 - For large vectors, this operation can be slow (\l{linear time}), + For large lists, this operation can be slow (\l{linear time}), because it requires moving all the items at indexes \a i and above by one position further in memory. If you want a container class that provides a fast insert() function, use std::list @@ -693,7 +693,7 @@ \overload Inserts \a count copies of \a value at index position \a i in the - vector. + list. Example: \snippet code/src_corelib_tools_qlist.cpp 10 @@ -740,7 +740,7 @@ Replaces the item at index position \a i with \a value. - \a i must be a valid index position in the vector (i.e., 0 <= \a + \a i must be a valid index position in the list (i.e., 0 <= \a i < size()). \sa operator[](), remove() @@ -759,7 +759,7 @@ \overload - Removes \a count elements from the middle of the vector, starting at + Removes \a count elements from the middle of the list, starting at index position \a i. \sa insert(), replace(), fill() @@ -783,7 +783,7 @@ \since 5.4 Removes all elements that compare equal to \a t from the - vector. Returns the number of elements removed, if any. + list. Returns the number of elements removed, if any. Provided for compatibility with QList. @@ -794,7 +794,7 @@ \since 5.4 Removes the first element that compares equal to \a t from the - vector. Returns whether an element was, in fact, removed. + list. Returns whether an element was, in fact, removed. Provided for compatibility with QList. @@ -840,9 +840,9 @@ /*! \fn template void QList::removeFirst() \since 5.1 - Removes the first item in the vector. Calling this function is - equivalent to calling remove(0). The vector must not be empty. If - the vector can be empty, call isEmpty() before calling this + Removes the first item in the list. Calling this function is + equivalent to calling remove(0). The list must not be empty. If + the list can be empty, call isEmpty() before calling this function. \sa remove(), takeFirst(), isEmpty() @@ -850,9 +850,9 @@ /*! \fn template void QList::removeLast() \since 5.1 - Removes the last item in the vector. Calling this function is - equivalent to calling remove(size() - 1). The vector must not be - empty. If the vector can be empty, call isEmpty() before calling + Removes the last item in the list. Calling this function is + equivalent to calling remove(size() - 1). The list must not be + empty. If the list can be empty, call isEmpty() before calling this function. \sa remove(), takeLast(), removeFirst(), isEmpty() @@ -861,8 +861,8 @@ /*! \fn template T QList::takeFirst() \since 5.1 - Removes the first item in the vector and returns it. This function - assumes the vector is not empty. To avoid failure, call isEmpty() + Removes the first item in the list and returns it. This function + assumes the list is not empty. To avoid failure, call isEmpty() before calling this function. \sa takeLast(), removeFirst() @@ -872,7 +872,7 @@ \since 5.1 Removes the last item in the list and returns it. This function - assumes the vector is not empty. To avoid failure, call isEmpty() + assumes the list is not empty. To avoid failure, call isEmpty() before calling this function. If you don't use the return value, removeLast() is more @@ -895,8 +895,8 @@ /*! \fn template QList &QList::fill(const T &value, int size = -1) - Assigns \a value to all items in the vector. If \a size is - different from -1 (the default), the vector is resized to size \a + Assigns \a value to all items in the list. If \a size is + different from -1 (the default), the list is resized to size \a size beforehand. Example: @@ -908,7 +908,7 @@ /*! \fn template int QList::indexOf(const T &value, int from = 0) const Returns the index position of the first occurrence of \a value in - the vector, searching forward from index position \a from. + the list, searching forward from index position \a from. Returns -1 if no item matched. Example: @@ -923,7 +923,7 @@ /*! \fn template int QList::lastIndexOf(const T &value, int from = -1) const Returns the index position of the last occurrence of the value \a - value in the vector, searching backward from index position \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. @@ -938,7 +938,7 @@ /*! \fn template bool QList::contains(const T &value) const - Returns \c true if the vector contains an occurrence of \a value; + Returns \c true if the list contains an occurrence of \a value; otherwise returns \c false. This function requires the value type to have an implementation of @@ -950,7 +950,7 @@ /*! \fn template bool QList::startsWith(const T &value) const \since 4.5 - Returns \c true if this vector is not empty and its first + Returns \c true if this list is not empty and its first item is equal to \a value; otherwise returns \c false. \sa isEmpty(), first() @@ -959,7 +959,7 @@ /*! \fn template bool QList::endsWith(const T &value) const \since 4.5 - Returns \c true if this vector is not empty and its last + Returns \c true if this list is not empty and its last item is equal to \a value; otherwise returns \c false. \sa isEmpty(), last() @@ -968,7 +968,7 @@ /*! \fn template int QList::count(const T &value) const - Returns the number of occurrences of \a value in the vector. + Returns the number of occurrences of \a value in the list. This function requires the value type to have an implementation of \c operator==(). @@ -985,8 +985,8 @@ /*! \fn template QList::iterator QList::begin() - Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in - the vector. + Returns an \l{STL-style iterators}{STL-style iterator} pointing to the + first item in the list. \sa constBegin(), end() */ @@ -1000,7 +1000,7 @@ \since 5.0 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item - in the vector. + in the list. \sa begin(), cend() */ @@ -1008,7 +1008,7 @@ /*! \fn template QList::const_iterator QList::constBegin() const Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item - in the vector. + in the list. \sa begin(), constEnd() */ @@ -1016,7 +1016,7 @@ /*! \fn template QList::iterator QList::end() Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item - after the last item in the vector. + after the last item in the list. \sa begin(), constEnd() */ @@ -1030,7 +1030,7 @@ \since 5.0 Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary - item after the last item in the vector. + item after the last item in the list. \sa cbegin(), end() */ @@ -1038,7 +1038,7 @@ /*! \fn template QList::const_iterator QList::constEnd() const Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary - item after the last item in the vector. + item after the last item in the list. \sa constBegin(), end() */ @@ -1047,7 +1047,7 @@ \since 5.6 Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first - item in the vector, in reverse order. + item in the list, in reverse order. \sa begin(), crbegin(), rend() */ @@ -1061,7 +1061,7 @@ \since 5.6 Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first - item in the vector, in reverse order. + item in the list, in reverse order. \sa begin(), rbegin(), rend() */ @@ -1070,7 +1070,7 @@ \since 5.6 Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past - the last item in the vector, in reverse order. + the last item in the list, in reverse order. \sa end(), crend(), rbegin() */ @@ -1084,7 +1084,7 @@ \since 5.6 Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one - past the last item in the vector, in reverse order. + past the last item in the list, in reverse order. \sa end(), rend(), rbegin() */ @@ -1092,7 +1092,7 @@ /*! \fn template QList::iterator QList::erase(iterator pos) Removes the item pointed to by the iterator \a pos from the - vector, and returns an iterator to the next item in the vector + list, and returns an iterator to the next item in the list (which may be end()). \sa insert(), remove() @@ -1109,8 +1109,8 @@ /*! \fn template T& QList::first() - Returns a reference to the first item in the vector. This - function assumes that the vector isn't empty. + Returns a reference to the first item in the list. This + function assumes that the list isn't empty. \sa last(), isEmpty(), constFirst() */ @@ -1123,16 +1123,16 @@ /*! \fn template const T& QList::constFirst() const \since 5.6 - Returns a const reference to the first item in the vector. This - function assumes that the vector isn't empty. + Returns a const reference to the first item in the list. This + function assumes that the list isn't empty. \sa constLast(), isEmpty(), first() */ /*! \fn template T& QList::last() - Returns a reference to the last item in the vector. This function - assumes that the vector isn't empty. + Returns a reference to the last item in the list. This function + assumes that the list isn't empty. \sa first(), isEmpty(), constLast() */ @@ -1145,15 +1145,15 @@ /*! \fn template const T& QList::constLast() const \since 5.6 - Returns a const reference to the last item in the vector. This function - assumes that the vector isn't empty. + Returns a const reference to the last item in the list. This function + assumes that the list isn't empty. \sa constFirst(), isEmpty(), last() */ /*! \fn template T QList::value(int i) const - Returns the value at index position \a i in the vector. + 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 @@ -1234,14 +1234,14 @@ /*! \fn template bool QList::empty() const This function is provided for STL compatibility. It is equivalent - to isEmpty(), returning \c true if the vector is empty; otherwise + to isEmpty(), returning \c true if the list is empty; otherwise returns \c false. */ /*! \fn template QList &QList::operator+=(const QList &other) - Appends the items of the \a other vector to this vector and - returns a reference to this vector. + Appends the items of the \a other list to this list and + returns a reference to this list. \sa operator+(), append() */ @@ -1250,7 +1250,7 @@ \overload - Appends \a value to the vector. + Appends \a value to the list. \sa append(), operator<<() */ @@ -1265,16 +1265,15 @@ /*! \fn template QList QList::operator+(const QList &other) const - Returns a vector that contains all the items in this vector - followed by all the items in the \a other vector. + Returns a list that contains all the items in this list + followed by all the items in the \a other list. \sa operator+=() */ /*! \fn template QList &QList::operator<<(const T &value) - Appends \a value to the vector and returns a reference to this - vector. + Appends \a value to the list and returns a reference to this list. \sa append(), operator+=() */ @@ -1290,8 +1289,7 @@ /*! \fn template QList &QList::operator<<(const QList &other) - Appends \a other to the vector and returns a reference to the - vector. + Appends \a other to the list and returns a reference to the list. */ /*! \typedef QList::iterator @@ -1308,7 +1306,7 @@ while iterators are active on that container. For more information, read \l{Implicit sharing iterator problem}. - \sa QList::begin(), QList::end(), QList::const_iterator, QMutableVectorIterator + \sa QList::begin(), QList::end(), QList::const_iterator, QMutableListIterator */ /*! \typedef QList::const_iterator @@ -1451,20 +1449,20 @@ \sa fromStdVector(), QList::toStdList() */ -/*! \fn template QDataStream &operator<<(QDataStream &out, const QList &vector) +/*! \fn template QDataStream &operator<<(QDataStream &out, const QList &list) \relates QList - Writes the vector \a vector to stream \a out. + Writes the list \a list to stream \a out. This function requires the value type to implement \c operator<<(). \sa{Serializing Qt Data Types}{Format of the QDataStream operators} */ -/*! \fn template QDataStream &operator>>(QDataStream &in, QList &vector) +/*! \fn template QDataStream &operator>>(QDataStream &in, QList &list) \relates QList - Reads a vector from stream \a in into \a vector. + Reads a list from stream \a in into \a list. This function requires the value type to implement \c operator>>(). diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 6371419ae5..5970081d85 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -66,20 +66,20 @@ compiler won't let you, for example, store a QWidget as a value; instead, store a QWidget *. - QVarLengthArray, like QVector, provides a resizable array data + QVarLengthArray, like QList, provides a resizable array data structure. The main differences between the two classes are: \list \li QVarLengthArray's API is much more low-level and it lacks - some of QVector's functionality. + some of QList's functionality. \li QVarLengthArray doesn't initialize the memory if the value is - a basic type. (QVector always does.) + a basic type. (QList always does.) - \li QVector uses \l{implicit sharing} as a memory optimization. - QVarLengthArray doesn't provide that feature; however, it - usually produces slightly better performance due to reduced - overhead, especially in tight loops. + \li QList uses \l{implicit sharing} as a memory optimization. + QVarLengthArray doesn't provide that feature; however, it + usually produces slightly better performance due to reduced + overhead, especially in tight loops. \endlist In summary, QVarLengthArray is a low-level optimization class @@ -87,7 +87,7 @@ places inside Qt and was added to Qt's public API for the convenience of advanced users. - \sa QVector, QList + \sa QList */ /*! \fn template QVarLengthArray::QVarLengthArray(qsizetype size) diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 9bdf925b00..ea68b21898 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -1084,7 +1084,7 @@ void tst_Collections::stack() stack.push(1); stack.push(2); stack.push(3); - QVectorIterator i = stack; + QListIterator i = stack; i.toBack(); int sum = 0; while (i.hasPrevious())