summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp (renamed from src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp)53
-rw-r--r--src/corelib/global/qtypeinfo.h2
-rw-r--r--src/corelib/itemmodels/qitemselectionmodel.h2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp2
-rw-r--r--src/corelib/kernel/qmetatype.h10
-rw-r--r--src/corelib/text/qbytearraylist.h16
-rw-r--r--src/corelib/text/qstring.h1
-rw-r--r--src/corelib/text/qstringalgorithms.h3
-rw-r--r--src/corelib/text/qstringlist.h70
-rw-r--r--src/corelib/text/qstringtokenizer.h2
-rw-r--r--src/corelib/tools/qcontainerfwd.h4
-rw-r--r--src/corelib/tools/qlist.cpp8
-rw-r--r--src/corelib/tools/qlist.h756
-rw-r--r--src/corelib/tools/qlist.qdoc (renamed from src/corelib/tools/qvector.qdoc)509
-rw-r--r--src/corelib/tools/qvector.h755
-rw-r--r--src/gui/image/qimage.h2
-rw-r--r--src/gui/painting/qregion.h2
-rw-r--r--src/gui/text/qtextdocument.h2
-rw-r--r--src/gui/text/qtextengine_p.h6
-rw-r--r--src/network/access/qhsts_p.h3
-rw-r--r--src/network/ssl/qdtls.h2
-rw-r--r--src/plugins/generic/tuiotouch/qoscbundle_p.h14
-rw-r--r--src/plugins/generic/tuiotouch/qoscmessage_p.h5
-rw-r--r--src/sql/kernel/qsqlcachedresult_p.h2
-rw-r--r--src/sql/kernel/qsqlresult.h3
-rw-r--r--src/widgets/kernel/qlayoutengine_p.h3
-rw-r--r--sync.profile2
-rw-r--r--tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp33
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp6
-rw-r--r--tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp2
-rw-r--r--tests/auto/corelib/tools/CMakeLists.txt2
-rw-r--r--tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp2
-rw-r--r--tests/auto/corelib/tools/qlist/.gitignore (renamed from tests/auto/corelib/tools/qvector/.gitignore)0
-rw-r--r--tests/auto/corelib/tools/qlist/CMakeLists.txt (renamed from tests/auto/corelib/tools/qvector/CMakeLists.txt)4
-rw-r--r--tests/auto/corelib/tools/qlist/qlist.pro (renamed from tests/auto/corelib/tools/qvector/qvector.pro)4
-rw-r--r--tests/auto/corelib/tools/qlist/tst_qlist.cpp (renamed from tests/auto/corelib/tools/qvector/tst_qvector.cpp)722
-rw-r--r--tests/auto/corelib/tools/tools.pro2
-rw-r--r--tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp2
-rw-r--r--tests/auto/tools/moc/allmocs_baseline_in.json12
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp22
40 files changed, 1506 insertions, 1546 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp
index 76a8d68f64..cdf1ae0eb1 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlist.cpp
@@ -49,18 +49,18 @@
****************************************************************************/
//! [0]
-QVector<int> integerVector;
-QVector<QString> stringVector;
+QList<int> integerVector;
+QList<QString> stringVector;
//! [0]
//! [1]
-QVector<QString> vector(200);
+QList<QString> vector(200);
//! [1]
//! [2]
-QVector<QString> vector(200, "Pass");
+QList<QString> vector(200, "Pass");
//! [2]
@@ -86,7 +86,7 @@ if (i != -1)
//! [6]
-QVector<int> vector(10);
+QList<int> vector(10);
int *data = vector.data();
for (int i = 0; i < 10; ++i)
data[i] = 2 * i;
@@ -94,7 +94,7 @@ for (int i = 0; i < 10; ++i)
//! [7]
-QVector<QString> vector;
+QList<QString> vector;
vector.append("one");
vector.append("two");
QString three = "three";
@@ -105,7 +105,7 @@ vector.append(three);
//! [move-append]
-QVector<QString> vector;
+QList<QString> vector;
vector.append("one");
vector.append("two");
QString three = "three";
@@ -116,14 +116,14 @@ vector.append(std::move(three));
//! [emplace]
-QVector<QString> vector{"a", "ccc"};
+QList<QString> vector{"a", "ccc"};
vector.emplace(1, 2, 'b');
// vector: ["a", "bb", "ccc"]
//! [emplace]
//! [emplace-back]
-QVector<QString> vector{"one", "two"};
+QList<QString> vector{"one", "two"};
vector.emplaceBack(3, 'a');
qDebug() << vector;
// vector: ["one", "two", "aaa"]
@@ -131,7 +131,7 @@ qDebug() << vector;
//! [emplace-back-ref]
-QVector<QString> vector;
+QList<QString> vector;
auto &ref = vector.emplaceBack();
ref = "one";
// vector: ["one"]
@@ -139,7 +139,7 @@ ref = "one";
//! [8]
-QVector<QString> vector;
+QList<QString> vector;
vector.prepend("one");
vector.prepend("two");
vector.prepend("three");
@@ -148,7 +148,7 @@ vector.prepend("three");
//! [9]
-QVector<QString> vector;
+QList<QString> vector;
vector << "alpha" << "beta" << "delta";
vector.insert(2, "gamma");
// vector: ["alpha", "beta", "gamma", "delta"]
@@ -156,7 +156,7 @@ vector.insert(2, "gamma");
//! [10]
-QVector<double> vector;
+QList<double> 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]
@@ -164,7 +164,7 @@ vector.insert(1, 3, 9.9);
//! [11]
-QVector<QString> vector(3);
+QList<QString> vector(3);
vector.fill("Yes");
// vector: ["Yes", "Yes", "Yes"]
@@ -174,7 +174,7 @@ vector.fill("oh", 5);
//! [12]
-QVector<QString> vector;
+QList<QString> vector;
vector << "A" << "B" << "C" << "B" << "A";
vector.indexOf("B"); // returns 1
vector.indexOf("B", 1); // returns 1
@@ -192,37 +192,18 @@ vector.lastIndexOf("B", 2); // returns 1
vector.lastIndexOf("X"); // returns -1
//! [13]
-
-//! [14]
-QVector<double> vect;
-vect << "red" << "green" << "blue" << "black";
-
-QList<double> list = vect.toList();
-// list: ["red", "green", "blue", "black"]
-//! [14]
-
-
-//! [15]
-QStringList list;
-list << "Sven" << "Kim" << "Ola";
-
-QVector<QString> vect = QVector<QString>::fromList(list);
-// vect: ["Sven", "Kim", "Ola"]
-//! [15]
-
-
//! [16]
std::vector<double> stdvector;
vector.push_back(1.2);
vector.push_back(0.5);
vector.push_back(3.14);
-QVector<double> vector = QVector<double>::fromStdVector(stdvector);
+QList<double> vector = QList<double>::fromStdVector(stdvector);
//! [16]
//! [17]
-QVector<double> vector;
+QList<double> vector;
vector << 1.2 << 0.5 << 3.14;
std::vector<double> stdvector = vector.toStdVector();
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index 175d5205af..121c9fdcd8 100644
--- a/src/corelib/global/qtypeinfo.h
+++ b/src/corelib/global/qtypeinfo.h
@@ -182,7 +182,7 @@ public: \
}; \
}
-Q_DECLARE_MOVABLE_CONTAINER(QVector);
+Q_DECLARE_MOVABLE_CONTAINER(QList);
Q_DECLARE_MOVABLE_CONTAINER(QQueue);
Q_DECLARE_MOVABLE_CONTAINER(QStack);
Q_DECLARE_MOVABLE_CONTAINER(QSet);
diff --git a/src/corelib/itemmodels/qitemselectionmodel.h b/src/corelib/itemmodels/qitemselectionmodel.h
index 529dc6f100..c1ce49521c 100644
--- a/src/corelib/itemmodels/qitemselectionmodel.h
+++ b/src/corelib/itemmodels/qitemselectionmodel.h
@@ -223,7 +223,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QItemSelectionModel::SelectionFlags)
# define Q_TEMPLATE_EXTERN extern
# endif
# endif
-Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QVector<QItemSelectionRange>;
+Q_TEMPLATE_EXTERN template class Q_CORE_EXPORT QList<QItemSelectionRange>;
#endif // Q_CC_MSVC
class Q_CORE_EXPORT QItemSelection : public QList<QItemSelectionRange>
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 6799057080..c20fb5b6e0 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -682,7 +682,7 @@ static void argumentTypesFromString(const char *str, const char *end,
++str;
}
QByteArray argType(begin, str - begin);
- argType.replace("QList<", "QVector<");
+ argType.replace("QVector<", "QList<");
types += QArgumentType(std::move(argType));
}
}
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 196df677e9..c7e754cb5c 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -232,7 +232,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
TypeName = Id,
#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \
- F(QVector) \
+ F(QList) \
F(QQueue) \
F(QStack) \
F(QSet) \
@@ -2014,7 +2014,7 @@ typedef QHash<QString, QVariant> QVariantHash;
#ifdef Q_CLANG_QDOC
class QByteArrayList;
#else
-typedef QVector<QByteArray> QByteArrayList;
+using QByteArrayList = QList<QByteArray>;
#endif
#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
@@ -2515,9 +2515,9 @@ public:
}
#endif
- if (skipToken(begin, end, "QList")) {
- // Replace QList by QVector
- appendStr("QVector");
+ if (skipToken(begin, end, "QVector")) {
+ // Replace QVector by QList
+ appendStr("QList");
}
if (skipToken(begin, end, "QPair")) {
diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h
index d02fa6d20f..3f85a24329 100644
--- a/src/corelib/text/qbytearraylist.h
+++ b/src/corelib/text/qbytearraylist.h
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
#ifndef QBYTEARRAYLIST_H
#define QBYTEARRAYLIST_H
@@ -49,12 +49,12 @@
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
-typedef QVectorIterator<QByteArray> QByteArrayListIterator;
-typedef QMutableVectorIterator<QByteArray> QMutableByteArrayListIterator;
+typedef QListIterator<QByteArray> QByteArrayListIterator;
+typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
#endif
#ifndef Q_CLANG_QDOC
-typedef QVector<QByteArray> QByteArrayList;
+typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
@@ -63,14 +63,14 @@ namespace QtPrivate {
#endif
#ifdef Q_CLANG_QDOC
-class QByteArrayList : public QVector<QByteArray>
+class QByteArrayList : public QList<QByteArray>
#else
-template <> struct QVectorSpecialMethods<QByteArray>
+template <> struct QListSpecialMethods<QByteArray>
#endif
{
#ifndef Q_CLANG_QDOC
protected:
- ~QVectorSpecialMethods() = default;
+ ~QListSpecialMethods() = default;
#endif
public:
inline QByteArray join() const
@@ -81,7 +81,7 @@ public:
{ return QtPrivate::QByteArrayList_join(self(), &sep, 1); }
private:
- typedef QVector<QByteArray> Self;
+ typedef QList<QByteArray> Self;
Self *self() { return static_cast<Self *>(this); }
const Self *self() const { return static_cast<const Self *>(this); }
};
diff --git a/src/corelib/text/qstring.h b/src/corelib/text/qstring.h
index 77a95c6280..f14644d956 100644
--- a/src/corelib/text/qstring.h
+++ b/src/corelib/text/qstring.h
@@ -77,7 +77,6 @@ class QRegularExpressionMatch;
class QString;
class QStringList;
class QStringRef;
-template <typename T> class QVector;
namespace QtPrivate {
template <bool...B> class BoolList;
diff --git a/src/corelib/text/qstringalgorithms.h b/src/corelib/text/qstringalgorithms.h
index f1aa052eac..3b67739232 100644
--- a/src/corelib/text/qstringalgorithms.h
+++ b/src/corelib/text/qstringalgorithms.h
@@ -41,7 +41,7 @@
#define QSTRINGALGORITHMS_H
#include <QtCore/qnamespace.h>
-
+#include <QtCore/qcontainerfwd.h>
#if 0
#pragma qt_class(QStringAlgorithms)
#endif
@@ -52,7 +52,6 @@ class QByteArray;
class QLatin1String;
class QStringView;
class QChar;
-template <typename T> class QVector;
namespace QtPrivate {
diff --git a/src/corelib/text/qstringlist.h b/src/corelib/text/qstringlist.h
index b94671746b..9c4daedd4b 100644
--- a/src/corelib/text/qstringlist.h
+++ b/src/corelib/text/qstringlist.h
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtCore/qvector.h>
+#include <QtCore/qlist.h>
#ifndef QSTRINGLIST_H
#define QSTRINGLIST_H
@@ -53,21 +53,21 @@ QT_BEGIN_NAMESPACE
class QRegularExpression;
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
-typedef QVectorIterator<QString> QStringListIterator;
-typedef QMutableVectorIterator<QString> QMutableStringListIterator;
+using QStringListIterator = QListIterator<QString>;
+using QMutableStringListIterator = QMutableListIterator<QString>;
#endif
class QStringList;
#ifdef Q_QDOC
-class QStringList : public QVector<QString>
+class QStringList : public QList<QString>
#else
-template <> struct QVectorSpecialMethods<QString>
+template <> struct QListSpecialMethods<QString>
#endif
{
#ifndef Q_QDOC
protected:
- ~QVectorSpecialMethods() = default;
+ ~QListSpecialMethods() = default;
#endif
public:
inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
@@ -101,23 +101,23 @@ private:
};
// ### Qt6: check if there's a better way
-class QStringList : public QVector<QString>
+class QStringList : public QList<QString>
{
#endif
public:
inline QStringList() noexcept { }
inline explicit QStringList(const QString &i) { append(i); }
- inline QStringList(const QVector<QString> &l) : QVector<QString>(l) { }
- inline QStringList(QVector<QString> &&l) noexcept : QVector<QString>(std::move(l)) { }
- inline QStringList(std::initializer_list<QString> args) : QVector<QString>(args) { }
+ inline QStringList(const QList<QString> &l) : QList<QString>(l) { }
+ inline QStringList(QList<QString> &&l) noexcept : QList<QString>(std::move(l)) { }
+ inline QStringList(std::initializer_list<QString> args) : QList<QString>(args) { }
template <typename InputIterator, QtPrivate::IfIsInputIterator<InputIterator> = true>
inline QStringList(InputIterator first, InputIterator last)
- : QVector<QString>(first, last) { }
+ : QList<QString>(first, last) { }
- QStringList &operator=(const QVector<QString> &other)
- { QVector<QString>::operator=(other); return *this; }
- QStringList &operator=(QVector<QString> &&other) noexcept
- { QVector<QString>::operator=(std::move(other)); return *this; }
+ QStringList &operator=(const QList<QString> &other)
+ { QList<QString>::operator=(other); return *this; }
+ QStringList &operator=(QList<QString> &&other) noexcept
+ { QList<QString>::operator=(std::move(other)); return *this; }
#if QT_STRINGVIEW_LEVEL < 2
inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -131,7 +131,7 @@ public:
{ append(str); return *this; }
inline QStringList &operator<<(const QStringList &l)
{ *this += l; return *this; }
- inline QStringList &operator<<(const QVector<QString> &l)
+ inline QStringList &operator<<(const QList<QString> &l)
{ *this += l; return *this; }
inline int indexOf(QStringView str, int from = 0) const;
@@ -145,16 +145,16 @@ public:
inline int lastIndexOf(const QRegularExpression &re, int from = -1) const;
#endif // QT_CONFIG(regularexpression)
- using QVector<QString>::indexOf;
- using QVector<QString>::lastIndexOf;
+ using QList<QString>::indexOf;
+ using QList<QString>::lastIndexOf;
};
Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
#ifndef Q_QDOC
-inline QStringList *QVectorSpecialMethods<QString>::self()
+inline QStringList *QListSpecialMethods<QString>::self()
{ return static_cast<QStringList *>(this); }
-inline const QStringList *QVectorSpecialMethods<QString>::self() const
+inline const QStringList *QListSpecialMethods<QString>::self() const
{ return static_cast<const QStringList *>(this); }
namespace QtPrivate {
@@ -190,45 +190,45 @@ namespace QtPrivate {
#endif // QT_CONFIG(regularexpression)
}
-inline void QVectorSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
+inline void QListSpecialMethods<QString>::sort(Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_sort(self(), cs);
}
-inline int QVectorSpecialMethods<QString>::removeDuplicates()
+inline int QListSpecialMethods<QString>::removeDuplicates()
{
return QtPrivate::QStringList_removeDuplicates(self());
}
#if QT_STRINGVIEW_LEVEL < 2
-inline QString QVectorSpecialMethods<QString>::join(const QString &sep) const
+inline QString QListSpecialMethods<QString>::join(const QString &sep) const
{
return QtPrivate::QStringList_join(self(), sep.constData(), sep.length());
}
#endif
-inline QString QVectorSpecialMethods<QString>::join(QStringView sep) const
+inline QString QListSpecialMethods<QString>::join(QStringView sep) const
{
return QtPrivate::QStringList_join(self(), sep);
}
-QString QVectorSpecialMethods<QString>::join(QLatin1String sep) const
+QString QListSpecialMethods<QString>::join(QLatin1String sep) const
{
return QtPrivate::QStringList_join(*self(), sep);
}
-inline QString QVectorSpecialMethods<QString>::join(QChar sep) const
+inline QString QListSpecialMethods<QString>::join(QChar sep) const
{
return QtPrivate::QStringList_join(self(), &sep, 1);
}
-inline QStringList QVectorSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const
+inline QStringList QListSpecialMethods<QString>::filter(QStringView str, Qt::CaseSensitivity cs) const
{
return QtPrivate::QStringList_filter(self(), str, cs);
}
#if QT_STRINGVIEW_LEVEL < 2
-inline QStringList QVectorSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
+inline QStringList QListSpecialMethods<QString>::filter(const QString &str, Qt::CaseSensitivity cs) const
{
return QtPrivate::QStringList_filter(self(), str, cs);
}
@@ -251,33 +251,33 @@ inline bool QStringList::contains(QStringView str, Qt::CaseSensitivity cs) const
return QtPrivate::QStringList_contains(this, str, cs);
}
-inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, QStringView after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
#if QT_STRINGVIEW_LEVEL < 2
-inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), before, after, cs);
return *self();
}
-inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(QStringView before, const QString &after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), before, qToStringViewIgnoringNull(after), cs);
return *self();
}
-inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QString &before, QStringView after, Qt::CaseSensitivity cs)
{
QtPrivate::QStringList_replaceInStrings(self(), QStringView(before), after, cs);
return *self();
}
#endif
-inline QStringList operator+(const QVector<QString> &one, const QStringList &other)
+inline QStringList operator+(const QList<QString> &one, const QStringList &other)
{
QStringList n = one;
n += other;
@@ -305,13 +305,13 @@ inline int QStringList::lastIndexOf(QLatin1String string, int from) const
}
#if QT_CONFIG(regularexpression)
-inline QStringList &QVectorSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
+inline QStringList &QListSpecialMethods<QString>::replaceInStrings(const QRegularExpression &rx, const QString &after)
{
QtPrivate::QStringList_replaceInStrings(self(), rx, after);
return *self();
}
-inline QStringList QVectorSpecialMethods<QString>::filter(const QRegularExpression &rx) const
+inline QStringList QListSpecialMethods<QString>::filter(const QRegularExpression &rx) const
{
return QtPrivate::QStringList_filter(self(), rx);
}
diff --git a/src/corelib/text/qstringtokenizer.h b/src/corelib/text/qstringtokenizer.h
index 31bbbf01c8..d042fbbdab 100644
--- a/src/corelib/text/qstringtokenizer.h
+++ b/src/corelib/text/qstringtokenizer.h
@@ -40,11 +40,11 @@
#define QSTRINGTOKENIZER_H
#include <QtCore/qnamespace.h>
+#include <QtCore/qcontainerfwd.h>
QT_BEGIN_NAMESPACE
template <typename, typename> class QStringBuilder;
-template <typename> class QVector;
#if defined(Q_QDOC) || 1 || (defined(__cpp_range_based_for) && __cpp_range_based_for >= 201603)
# define Q_STRINGTOKENIZER_USE_SENTINEL
diff --git a/src/corelib/tools/qcontainerfwd.h b/src/corelib/tools/qcontainerfwd.h
index fd4701a8b1..715583e03b 100644
--- a/src/corelib/tools/qcontainerfwd.h
+++ b/src/corelib/tools/qcontainerfwd.h
@@ -56,8 +56,8 @@ template <class T> class QQueue;
template <class T> class QSet;
template <class T> class QStack;
template<class T, qsizetype Prealloc = 256> class QVarLengthArray;
-template <class T> class QVector;
-template<typename T> using QList = QVector<T>;
+template <class T> class QList;
+template<typename T> using QVector = QList<T>;
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index 62201fd5d6..cdcfc30f28 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -50,8 +50,8 @@ QT_BEGIN_NAMESPACE
/*
### Qt 5:
### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
- ### Qt exports QPolygon and QPolygonF that inherit QVector<QPoint> and
- ### QVector<QPointF> respectively.
+ ### Qt exports QPolygon and QPolygonF that inherit QList<QPoint> and
+ ### QList<QPointF> respectively.
*/
#if defined(Q_CC_MSVC) && defined(QT_BUILD_CORE_LIB)
@@ -59,8 +59,8 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include <QtCore/qpoint.h>
QT_END_INCLUDE_NAMESPACE
-template class Q_CORE_EXPORT QVector<QPointF>;
-template class Q_CORE_EXPORT QVector<QPoint>;
+template class Q_CORE_EXPORT QList<QPointF>;
+template class Q_CORE_EXPORT QList<QPoint>;
#endif
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 515fba6530..1c9a547395 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -1,6 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2019 Intel Corporation
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -40,18 +41,757 @@
#ifndef QLIST_H
#define QLIST_H
-#include <QtCore/qvector.h>
-#include <QtCore/qcontainerfwd.h>
+#include <QtCore/qarraydatapointer.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qhashfunctions.h>
+#include <QtCore/qiterator.h>
+
+#include <functional>
+#include <limits>
+#include <initializer_list>
+#include <type_traits>
-#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
QT_BEGIN_NAMESPACE
+
+namespace QtPrivate {
+ template <typename V, typename U> int indexOf(const QList<V> &list, const U &u, int from);
+ template <typename V, typename U> int lastIndexOf(const QList<V> &list, const U &u, int from);
+}
+
+template <typename T> struct QListSpecialMethods
+{
+protected:
+ ~QListSpecialMethods() = default;
+};
+template <> struct QListSpecialMethods<QByteArray>;
+template <> struct QListSpecialMethods<QString>;
+
+template <typename T>
+class QList
+#ifndef Q_QDOC
+ : public QListSpecialMethods<T>
+#endif
+{
+ typedef QTypedArrayData<T> Data;
+ typedef QArrayDataOps<T> DataOps;
+ typedef QArrayDataPointer<T> DataPointer;
+ class DisableRValueRefs {};
+
+ DataPointer d;
+
+ template <typename V, typename U> friend int QtPrivate::indexOf(const QList<V> &list, const U &u, int from);
+ template <typename V, typename U> friend int QtPrivate::lastIndexOf(const QList<V> &list, const U &u, int from);
+
+public:
+ typedef T Type;
+ typedef T value_type;
+ typedef value_type *pointer;
+ typedef const value_type *const_pointer;
+ typedef value_type &reference;
+ typedef const value_type &const_reference;
+ typedef int size_type;
+ typedef qptrdiff difference_type;
+ typedef typename Data::iterator iterator;
+ typedef typename Data::const_iterator const_iterator;
+ typedef iterator Iterator;
+ typedef const_iterator ConstIterator;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef typename DataPointer::parameter_type parameter_type;
+ using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
+
+private:
+ void resize_internal(int i, Qt::Initialization);
+ bool isValidIterator(const_iterator i) const
+ {
+ const std::less<const T*> less = {};
+ return !less(d->end(), i) && !less(i, d->begin());
+ }
+public:
+ QList(DataPointer dd) noexcept
+ : d(dd)
+ {
+ }
+
+public:
+ constexpr inline QList() noexcept { }
+ explicit QList(int size)
+ : d(Data::allocate(size))
+ {
+ if (size)
+ d->appendInitialize(size);
+ }
+ QList(int size, const T &t)
+ : d(Data::allocate(size))
+ {
+ if (size)
+ d->copyAppend(size, t);
+ }
+
+ inline QList(const QList<T> &other) noexcept : d(other.d) {}
+ QList(QList<T> &&other) noexcept : d(std::move(other.d)) {}
+ inline QList(std::initializer_list<T> args)
+ : d(Data::allocate(args.size()))
+ {
+ if (args.size())
+ d->copyAppend(args.begin(), args.end());
+ }
+
+ ~QList() /*noexcept(std::is_nothrow_destructible<T>::value)*/ {}
+ QList<T> &operator=(const QList<T> &other) { d = other.d; return *this; }
+ QList &operator=(QList &&other) noexcept(std::is_nothrow_destructible<T>::value)
+ {
+ d = std::move(other.d);
+ return *this;
+ }
+ QList<T> &operator=(std::initializer_list<T> args)
+ {
+ d = DataPointer(Data::allocate(args.size()));
+ if (args.size())
+ d->copyAppend(args.begin(), args.end());
+ return *this;
+ }
+ template <typename InputIterator, QtPrivate::IfIsForwardIterator<InputIterator> = true>
+ QList(InputIterator i1, InputIterator i2)
+ : d(Data::allocate(std::distance(i1, i2)))
+ {
+ if (std::distance(i1, i2))
+ d->copyAppend(i1, i2);
+ }
+
+ template <typename InputIterator, QtPrivate::IfIsNotForwardIterator<InputIterator> = true>
+ QList(InputIterator i1, InputIterator i2)
+ : QList()
+ {
+ QtPrivate::reserveIfForwardIterator(this, i1, i2);
+ std::copy(i1, i2, std::back_inserter(*this));
+ }
+
+ void swap(QList<T> &other) noexcept { qSwap(d, other.d); }
+
+ friend bool operator==(const QList &l, const QList &r)
+ {
+ if (l.size() != r.size())
+ return false;
+ if (l.begin() == r.begin())
+ return true;
+
+ // do element-by-element comparison
+ return l.d->compare(l.begin(), r.begin(), l.size());
+ }
+ friend bool operator!=(const QList &l, const QList &r)
+ {
+ return !(l == r);
+ }
+
+ int size() const noexcept { return int(d->size); }
+ int count() const noexcept { return size(); }
+ int length() const noexcept { return size(); }
+
+ inline bool isEmpty() const noexcept { return d->size == 0; }
+
+ void resize(int size)
+ {
+ resize_internal(size, Qt::Uninitialized);
+ if (size > this->size())
+ d->appendInitialize(size);
+ }
+ void resize(int size, parameter_type c)
+ {
+ resize_internal(size, Qt::Uninitialized);
+ if (size > this->size())
+ d->copyAppend(size - this->size(), c);
+ }
+
+ inline int capacity() const { return int(d->constAllocatedCapacity()); }
+ void reserve(int size);
+ inline void squeeze();
+
+ void detach() { d.detach(); }
+ bool isDetached() const noexcept { return !d->isShared(); }
+
+ inline bool isSharedWith(const QList<T> &other) const { return d == other.d; }
+
+ pointer data() { detach(); return d->data(); }
+ const_pointer data() const noexcept { return d->data(); }
+ const_pointer constData() const noexcept { return d->data(); }
+ void clear() {
+ if (!size())
+ return;
+ if (d->needsDetach()) {
+ // must allocate memory
+ DataPointer detached(Data::allocate(d.allocatedCapacity(), d->detachFlags()));
+ d.swap(detached);
+ } else {
+ d->truncate(0);
+ }
+ }
+
+ const_reference at(int i) const noexcept
+ {
+ Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::at", "index out of range");
+ return data()[i];
+ }
+ reference operator[](int i)
+ {
+ Q_ASSERT_X(size_t(i) < size_t(d->size), "QList::operator[]", "index out of range");
+ detach();
+ return data()[i];
+ }
+ const_reference operator[](int i) const noexcept { return at(i); }
+ void append(const_reference t)
+ { append(const_iterator(std::addressof(t)), const_iterator(std::addressof(t)) + 1); }
+ void append(const_iterator i1, const_iterator i2);
+ void append(rvalue_ref t) { emplaceBack(std::move(t)); }
+ void append(const QList<T> &l) { append(l.constBegin(), l.constEnd()); }
+ void prepend(rvalue_ref t);
+ void prepend(const T &t);
+
+ template <typename ...Args>
+ reference emplaceBack(Args&&... args) { return *emplace(count(), std::forward<Args>(args)...); }
+
+ iterator insert(int i, parameter_type t)
+ { return insert(i, 1, t); }
+ iterator insert(int i, int n, parameter_type t);
+ iterator insert(const_iterator before, parameter_type t)
+ {
+ Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
+ return insert(before, 1, t);
+ }
+ iterator insert(const_iterator before, int n, parameter_type t)
+ {
+ Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
+ return insert(std::distance(constBegin(), before), n, t);
+ }
+ iterator insert(const_iterator before, rvalue_ref t)
+ {
+ Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
+ return insert(std::distance(constBegin(), before), std::move(t));
+ }
+ iterator insert(int i, rvalue_ref t) { return emplace(i, std::move(t)); }
+
+ template <typename ...Args>
+ iterator emplace(const_iterator before, Args&&... args)
+ {
+ Q_ASSERT_X(isValidIterator(before), "QList::emplace", "The specified iterator argument 'before' is invalid");
+ return emplace(std::distance(constBegin(), before), std::forward<Args>(args)...);
+ }
+
+ template <typename ...Args>
+ iterator emplace(int i, Args&&... args);
+#if 0
+ template< class InputIt >
+ iterator insert( const_iterator pos, InputIt first, InputIt last );
+ iterator insert( const_iterator pos, std::initializer_list<T> ilist );
+#endif
+ void replace(int i, const T &t)
+ {
+ Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
+ const T copy(t);
+ data()[i] = copy;
+ }
+ void replace(int i, rvalue_ref t)
+ {
+ Q_ASSERT_X(i >= 0 && i < d->size, "QList<T>::replace", "index out of range");
+ const T copy(std::move(t));
+ data()[i] = std::move(copy);
+ }
+
+ void remove(int i, int n = 1);
+ void removeFirst() { Q_ASSERT(!isEmpty()); remove(0); }
+ void removeLast() { Q_ASSERT(!isEmpty()); remove(size() - 1); }
+ value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); remove(0); return v; }
+ value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); remove(size() - 1); return v; }
+
+ QList<T> &fill(parameter_type t, int size = -1);
+
+ int indexOf(const T &t, int from = 0) const noexcept;
+ int lastIndexOf(const T &t, int from = -1) const noexcept;
+ bool contains(const T &t) const noexcept
+ {
+ return indexOf(t) != -1;
+ }
+ int count(const T &t) const noexcept
+ {
+ return int(std::count(&*cbegin(), &*cend(), t));
+ }
+
+ // QList compatibility
+ void removeAt(int i) { remove(i); }
+ int removeAll(const T &t)
+ {
+ const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t);
+ if (cit == ce)
+ return 0;
+ int index = cit - this->cbegin();
+ // next operation detaches, so ce, cit, t may become invalidated:
+ const T tCopy = t;
+ const iterator e = end(), it = std::remove(begin() + index, e, tCopy);
+ const int result = std::distance(it, e);
+ erase(it, e);
+ return result;
+ }
+ bool removeOne(const T &t)
+ {
+ const int i = indexOf(t);
+ if (i < 0)
+ return false;
+ remove(i);
+ return true;
+ }
+ T takeAt(int i) { T t = std::move((*this)[i]); remove(i); return t; }
+ void move(int from, int to)
+ {
+ Q_ASSERT_X(from >= 0 && from < size(), "QList::move(int,int)", "'from' is out-of-range");
+ Q_ASSERT_X(to >= 0 && to < size(), "QList::move(int,int)", "'to' is out-of-range");
+ if (from == to) // don't detach when no-op
+ return;
+ detach();
+ T * const b = d->begin();
+ if (from < to)
+ std::rotate(b + from, b + from + 1, b + to + 1);
+ else
+ std::rotate(b + to, b + from, b + from + 1);
+ }
+
+ // STL-style
+ iterator begin() { detach(); return d->begin(); }
+ iterator end() { detach(); return d->end(); }
+
+ const_iterator begin() const noexcept { return d->constBegin(); }
+ const_iterator end() const noexcept { return d->constEnd(); }
+ const_iterator cbegin() const noexcept { return d->constBegin(); }
+ const_iterator cend() const noexcept { return d->constEnd(); }
+ const_iterator constBegin() const noexcept { return d->constBegin(); }
+ const_iterator constEnd() const noexcept { return d->constEnd(); }
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
+ reverse_iterator rend() { return reverse_iterator(begin()); }
+ const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
+ const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
+ const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
+ const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
+
+ iterator erase(const_iterator begin, const_iterator end);
+ inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
+
+ // more Qt
+ inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
+ inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
+ inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
+ inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
+ inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
+ QList<T> mid(int pos, int len = -1) const;
+
+ T value(int i) const { return value(i, T()); }
+ T value(int i, const T &defaultValue) const;
+
+ void swapItemsAt(int i, int j) {
+ Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(),
+ "QList<T>::swap", "index out of range");
+ detach();
+ qSwap(d->begin()[i], d->begin()[j]);
+ }
+
+ // STL compatibility
+ inline void push_back(const T &t) { append(t); }
+ void push_back(rvalue_ref t) { append(std::move(t)); }
+ void push_front(rvalue_ref t) { prepend(std::move(t)); }
+ inline void push_front(const T &t) { prepend(t); }
+ void pop_back() { removeLast(); }
+ void pop_front() { removeFirst(); }
+
+ template <typename ...Args>
+ reference emplace_back(Args&&... args) { return emplaceBack(std::forward<Args>(args)...); }
+
+ inline bool empty() const
+ { return d->size == 0; }
+ inline reference front() { return first(); }
+ inline const_reference front() const { return first(); }
+ inline reference back() { return last(); }
+ inline const_reference back() const { return last(); }
+ void shrink_to_fit() { squeeze(); }
+
+ // comfort
+ QList<T> &operator+=(const QList<T> &l) { append(l.cbegin(), l.cend()); return *this; }
+ inline QList<T> operator+(const QList<T> &l) const
+ { QList n = *this; n += l; return n; }
+ inline QList<T> &operator+=(const T &t)
+ { append(t); return *this; }
+ inline QList<T> &operator<< (const T &t)
+ { append(t); return *this; }
+ inline QList<T> &operator<<(const QList<T> &l)
+ { *this += l; return *this; }
+ inline QList<T> &operator+=(rvalue_ref t)
+ { append(std::move(t)); return *this; }
+ inline QList<T> &operator<<(rvalue_ref t)
+ { append(std::move(t)); return *this; }
+
+ // Consider deprecating in 6.4 or later
+ static QList<T> fromList(const QList<T> &list) { return list; }
+ QList<T> toList() const { return *this; }
+
+ static inline QList<T> fromVector(const QList<T> &vector) { return vector; }
+ inline QList<T> toVector() const { return *this; }
+};
+
+#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606
+template <typename InputIterator,
+ typename ValueType = typename std::iterator_traits<InputIterator>::value_type,
+ QtPrivate::IfIsInputIterator<InputIterator> = true>
+QList(InputIterator, InputIterator) -> QList<ValueType>;
+#endif
+
+template <typename T>
+inline void QList<T>::resize_internal(int newSize, Qt::Initialization)
+{
+ Q_ASSERT(newSize >= 0);
+
+ if (d->needsDetach() || newSize > capacity()) {
+ // must allocate memory
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize),
+ d->detachFlags()));
+ if (size() && newSize) {
+ detached->copyAppend(constBegin(), constBegin() + qMin(newSize, size()));
+ }
+ d.swap(detached);
+ }
+
+ if (newSize < size())
+ d->truncate(newSize);
+}
+
+template <typename T>
+void QList<T>::reserve(int asize)
+{
+ // capacity() == 0 for immutable data, so this will force a detaching below
+ if (asize <= capacity()) {
+ if (d->flags() & Data::CapacityReserved)
+ return; // already reserved, don't shrink
+ if (!d->isShared()) {
+ // accept current allocation, don't shrink
+ d->flags() |= Data::CapacityReserved;
+ return;
+ }
+ }
+
+ DataPointer detached(Data::allocate(qMax(asize, size()),
+ d->detachFlags() | Data::CapacityReserved));
+ detached->copyAppend(constBegin(), constEnd());
+ d.swap(detached);
+}
+
+template <typename T>
+inline void QList<T>::squeeze()
+{
+ if (d->needsDetach() || size() != capacity()) {
+ // must allocate memory
+ DataPointer detached(Data::allocate(size(), d->detachFlags() & ~Data::CapacityReserved));
+ if (size()) {
+ detached->copyAppend(constBegin(), constEnd());
+ }
+ d.swap(detached);
+ }
+}
+
+template <typename T>
+inline void QList<T>::remove(int i, int n)
+{
+ Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QList::remove", "index out of range");
+ Q_ASSERT_X(n >= 0, "QList::remove", "invalid count");
+
+ if (n == 0)
+ return;
+
+ const size_t newSize = size() - n;
+ if (d->needsDetach() ||
+ ((d->flags() & Data::CapacityReserved) == 0
+ && newSize < d->allocatedCapacity()/2)) {
+ // allocate memory
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize),
+ d->detachFlags() & ~(Data::GrowsBackwards | Data::GrowsForward)));
+ const_iterator where = constBegin() + i;
+ if (newSize) {
+ detached->copyAppend(constBegin(), where);
+ detached->copyAppend(where + n, constEnd());
+ }
+ d.swap(detached);
+ } else {
+ // we're detached and we can just move data around
+ d->erase(d->begin() + i, d->begin() + i + n);
+ }
+}
+
+template <typename T>
+inline void QList<T>::prepend(const T &t)
+{ insert(0, 1, t); }
+template <typename T>
+void QList<T>::prepend(rvalue_ref t)
+{ insert(0, std::move(t)); }
+
template<typename T>
-using QMutableListIterator = QMutableVectorIterator<T>;
-template<typename T>
-using QListIterator = QVectorIterator<T>;
-QT_END_NAMESPACE
+inline T QList<T>::value(int i, const T &defaultValue) const
+{
+ return size_t(i) < size_t(d->size) ? at(i) : defaultValue;
+}
+
+template <typename T>
+inline void QList<T>::append(const_iterator i1, const_iterator i2)
+{
+ if (i1 == i2)
+ return;
+ const size_t newSize = size() + std::distance(i1, i2);
+ if (d->needsDetach() || newSize > d->allocatedCapacity()) {
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize),
+ d->detachFlags() | Data::GrowsForward));
+ detached->copyAppend(constBegin(), constEnd());
+ detached->copyAppend(i1, i2);
+ d.swap(detached);
+ } else {
+ // we're detached and we can just move data around
+ d->copyAppend(i1, i2);
+ }
+}
+
+template <typename T>
+inline typename QList<T>::iterator
+QList<T>::insert(int i, int n, parameter_type t)
+{
+ Q_ASSERT_X(size_t(i) <= size_t(d->size), "QList<T>::insert", "index out of range");
+
+ // we don't have a quick exit for n == 0
+ // it's not worth wasting CPU cycles for that
+
+ const size_t newSize = size() + n;
+ if (d->needsDetach() || newSize > d->allocatedCapacity()) {
+ typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
+ if (size_t(i) <= newSize / 4)
+ flags |= Data::GrowsBackwards;
+
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
+ const_iterator where = constBegin() + i;
+ detached->copyAppend(constBegin(), where);
+ detached->copyAppend(n, t);
+ detached->copyAppend(where, constEnd());
+ d.swap(detached);
+ } else {
+ // we're detached and we can just move data around
+ if (i == size()) {
+ d->copyAppend(n, t);
+ } else {
+ T copy(t);
+ d->insert(d.begin() + i, n, copy);
+ }
+ }
+ return d.begin() + i;
+}
+
+template <typename T>
+template <typename ...Args>
+typename QList<T>::iterator
+QList<T>::emplace(int i, Args&&... args)
+{
+ Q_ASSERT_X(i >= 0 && i <= d->size, "QList<T>::insert", "index out of range");
+
+ const size_t newSize = size() + 1;
+ if (d->needsDetach() || newSize > d->allocatedCapacity()) {
+ typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
+ if (size_t(i) <= newSize / 4)
+ flags |= Data::GrowsBackwards;
+
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
+ const_iterator where = constBegin() + i;
+
+ // First, create an element to handle cases, when a user moves
+ // the element from a container to the same container
+ detached->createInPlace(detached.begin() + i, std::forward<Args>(args)...);
+
+ // Then, put the first part of the elements to the new location
+ detached->copyAppend(constBegin(), where);
+
+ // After that, increase the actual size, because we created
+ // one extra element
+ ++detached.size;
+
+ // Finally, put the rest of the elements to the new location
+ detached->copyAppend(where, constEnd());
+
+ d.swap(detached);
+ } else {
+ d->emplace(d.begin() + i, std::forward<Args>(args)...);
+ }
+ return d.begin() + i;
+}
+
+template <typename T>
+typename QList<T>::iterator QList<T>::erase(const_iterator abegin, const_iterator aend)
+{
+ Q_ASSERT_X(isValidIterator(abegin), "QList::erase", "The specified iterator argument 'abegin' is invalid");
+ Q_ASSERT_X(isValidIterator(aend), "QList::erase", "The specified iterator argument 'aend' is invalid");
+ Q_ASSERT(aend >= abegin);
+
+ int i = std::distance(d.constBegin(), abegin);
+ int n = std::distance(abegin, aend);
+ remove(i, n);
+
+ return d.begin() + i;
+}
+
+template <typename T>
+inline QList<T> &QList<T>::fill(parameter_type t, int newSize)
+{
+ if (newSize == -1)
+ newSize = size();
+ if (d->needsDetach() || newSize > capacity()) {
+ // must allocate memory
+ DataPointer detached(Data::allocate(d->detachCapacity(newSize),
+ d->detachFlags()));
+ detached->copyAppend(newSize, t);
+ d.swap(detached);
+ } else {
+ // we're detached
+ const T copy(t);
+ d->assign(d.begin(), d.begin() + qMin(size(), newSize), t);
+ if (newSize > size())
+ d->copyAppend(newSize - size(), copy);
+ }
+ return *this;
+}
+
+namespace QtPrivate {
+template <typename T, typename U>
+int indexOf(const QList<T> &vector, const U &u, int from)
+{
+ if (from < 0)
+ from = qMax(from + vector.size(), 0);
+ if (from < vector.size()) {
+ auto n = vector.begin() + from - 1;
+ auto e = vector.end();
+ while (++n != e)
+ if (*n == u)
+ return int(n - vector.begin());
+ }
+ return -1;
+}
+
+template <typename T, typename U>
+int lastIndexOf(const QList<T> &vector, const U &u, int from)
+{
+ if (from < 0)
+ from += vector.d->size;
+ else if (from >= vector.size())
+ from = vector.size() - 1;
+ if (from >= 0) {
+ auto b = vector.begin();
+ auto n = vector.begin() + from + 1;
+ while (n != b) {
+ if (*--n == u)
+ return int(n - b);
+ }
+ }
+ return -1;
+}
+}
+
+template <typename T>
+int QList<T>::indexOf(const T &t, int from) const noexcept
+{
+ return QtPrivate::indexOf<T, T>(*this, t, from);
+}
+
+template <typename T>
+int QList<T>::lastIndexOf(const T &t, int from) const noexcept
+{
+ return QtPrivate::lastIndexOf(*this, t, from);
+}
+
+template <typename T>
+inline QList<T> QList<T>::mid(int pos, int len) const
+{
+ qsizetype p = pos;
+ qsizetype l = len;
+ using namespace QtPrivate;
+ switch (QContainerImplHelper::mid(d.size, &p, &l)) {
+ case QContainerImplHelper::Null:
+ case QContainerImplHelper::Empty:
+ return QList();
+ case QContainerImplHelper::Full:
+ return *this;
+ case QContainerImplHelper::Subset:
+ break;
+ }
+
+ // Allocate memory
+ DataPointer copied(Data::allocate(l));
+ copied->copyAppend(constBegin() + p, constBegin() + p + l);
+ return copied;
+}
+
+Q_DECLARE_SEQUENTIAL_ITERATOR(List)
+Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(List)
+
+template <typename T>
+size_t qHash(const QList<T> &key, size_t seed = 0)
+ noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
+{
+ return qHashRange(key.cbegin(), key.cend(), seed);
+}
+
+template <typename T>
+auto operator<(const QList<T> &lhs, const QList<T> &rhs)
+ noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end())))
+ -> decltype(std::declval<T>() < std::declval<T>())
+{
+ return std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end());
+}
+
+template <typename T>
+auto operator>(const QList<T> &lhs, const QList<T> &rhs)
+ noexcept(noexcept(lhs < rhs))
+ -> decltype(lhs < rhs)
+{
+ return rhs < lhs;
+}
+
+template <typename T>
+auto operator<=(const QList<T> &lhs, const QList<T> &rhs)
+ noexcept(noexcept(lhs < rhs))
+ -> decltype(lhs < rhs)
+{
+ return !(lhs > rhs);
+}
+
+template <typename T>
+auto operator>=(const QList<T> &lhs, const QList<T> &rhs)
+ noexcept(noexcept(lhs < rhs))
+ -> decltype(lhs < rhs)
+{
+ return !(lhs < rhs);
+}
+
+/*
+ ### Qt 5:
+ ### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
+ ### Qt exports QPolygon and QPolygonF that inherit QList<QPoint> and
+ ### QList<QPointF> respectively.
+*/
+
+#if defined(Q_CC_MSVC) && !defined(QT_BUILD_CORE_LIB)
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <QtCore/qpoint.h>
+QT_END_INCLUDE_NAMESPACE
+extern template class Q_CORE_EXPORT QList<QPointF>;
+extern template class Q_CORE_EXPORT QList<QPoint>;
#endif
+QList<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
+
+QT_END_NAMESPACE
+
#include <QtCore/qbytearraylist.h>
#include <QtCore/qstringlist.h>
diff --git a/src/corelib/tools/qvector.qdoc b/src/corelib/tools/qlist.qdoc
index 88baaab8c1..c0af194858 100644
--- a/src/corelib/tools/qvector.qdoc
+++ b/src/corelib/tools/qlist.qdoc
@@ -28,82 +28,87 @@
/*!
\class QVector
\inmodule QtCore
- \brief The QVector class is a template class that provides a dynamic array.
+ \brief QVector is an alias for QList.
+
+ Please see the QList documentation for details.
+*/
+
+/*!
+ \class QList
+ \inmodule QtCore
+ \brief The QList class is a template class that provides a dynamic array.
\ingroup tools
\ingroup shared
\reentrant
- QVector\<T\> is one of Qt's generic \l{container classes}. It
+ QList\<T\> is one of Qt's generic \l{container classes}. It
stores its items in adjacent memory locations and provides fast
- index-based access.
+ index-based access. QVector\<T\> used to be a different class in
+ Qt 5, but is now a simple alias to QList.
- QList\<T\>, QVector\<T\>, and QVarLengthArray\<T\>
+ QList\<T\> and QVarLengthArray\<T\>
provide similar APIs and functionality. They are often interchangeable,
but there are performance consequences. Here is an overview of use cases:
\list
- \li QVector should be your default first choice.
- QVector\<T\> will usually give better performance than QList\<T\>,
- because QVector\<T\> always stores its items sequentially in memory,
- where QList\<T\> will allocate its items on the heap unless
- \c {sizeof(T) <= sizeof(void*)} and T has been declared to be
- either a \c{Q_MOVABLE_TYPE} or a \c{Q_PRIMITIVE_TYPE} using
- \l {Q_DECLARE_TYPEINFO}. See the \l {Pros and Cons of Using QList}
- for an explanation.
- \li However, QList is used throughout the Qt APIs for passing
- parameters and for returning values. Use QList to interface with
- those APIs.
+ \li QList should be your default first choice.
+ \li QVarLengthArray provides an array that reserves space on the stack,
+ but can dynamically grow onto the heap if required. It's good to
+ use for short lived containers that are usually small.
\li If you need a real linked list, which guarantees
\l{Algorithmic Complexity}{constant time} insertions mid-list and
uses iterators to items rather than indexes, use std::list.
\endlist
- \note QVector and QVarLengthArray both guarantee C-compatible
- array layout. QList does not. This might be important if your
- application must interface with a C API.
+ \note QList and QVarLengthArray both guarantee C-compatible
+ array layout.
+ \note QList in Qt 5 did not always have a C-compatible array layout and
+ we often recommended to use QVector instead for more predictable
+ performance. This is not the case in Qt 6 anymore, where both classes
+ now share an implementation and can be used interchangeably.
- Here's an example of a QVector that stores integers and a QVector
+ Here's an example of a QList that stores integers and a QList
that stores QString values:
- \snippet code/src_corelib_tools_qvector.cpp 0
+ \snippet code/src_corelib_tools_qlist.cpp 0
- QVector stores its items in a vector (array). Typically, vectors
+ QList stores its items in a vector (array). Typically, vectors
are created with an initial size. For example, the following code
- constructs a QVector with 200 elements:
+ constructs a QList with 200 elements:
- \snippet code/src_corelib_tools_qvector.cpp 1
+ \snippet code/src_corelib_tools_qlist.cpp 1
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
argument to the constructor:
- \snippet code/src_corelib_tools_qvector.cpp 2
+ \snippet code/src_corelib_tools_qlist.cpp 2
You can also call fill() at any time to fill the vector with a
value.
- QVector uses 0-based indexes, just like C++ arrays. To access the
+ 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
that can be used on the left side of an assignment:
- \snippet code/src_corelib_tools_qvector.cpp 3
+ \snippet code/src_corelib_tools_qlist.cpp 3
For read-only access, an alternative syntax is to use at():
- \snippet code/src_corelib_tools_qvector.cpp 4
+ \snippet code/src_corelib_tools_qlist.cpp 4
at() can be faster than operator[](), because it never causes a
\l{deep copy} to occur.
- Another way to access the data stored in a QVector is to call
+ 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
- need to pass a QVector to a function that accepts a plain C++
+ 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
@@ -112,13 +117,13 @@
backward. Both return the index of the matching item if they found
one; otherwise, they return -1. For example:
- \snippet code/src_corelib_tools_qvector.cpp 5
+ \snippet code/src_corelib_tools_qlist.cpp 5
If you simply want to check whether a vector contains a
particular value, use contains(). If you want to find out how
many times a particular value occurs in the vector, use count().
- QVector provides these basic functions to add, move, and remove
+ 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
@@ -126,22 +131,22 @@
class that provides fast insertion/removal in the middle, use
std::list instead.
- Unlike plain C++ arrays, QVectors can be resized at any time by
+ Unlike plain C++ arrays, QLists can be resized at any time by
calling resize(). If the new size is larger than the old size,
- QVector might need to reallocate the whole vector. QVector tries
+ QList might need to reallocate the whole vector. QList tries
to reduce the number of reallocations by preallocating up to twice
as much memory as the actual data needs.
- If you know in advance approximately how many items the QVector
- will contain, you can call reserve(), asking QVector to
+ If you know in advance approximately how many items the QList
+ will contain, you can call reserve(), asking QList to
preallocate a certain amount of memory. You can also call
- capacity() to find out how much memory QVector actually
+ capacity() to find out how much memory QList actually
allocated.
Note that using non-const operators and functions can cause
- QVector to do a deep copy of the data. This is due to \l{implicit sharing}.
+ QList to do a deep copy of the data. This is due to \l{implicit sharing}.
- QVector's value type must be an \l{assignable data type}. This
+ QList's value type must be an \l{assignable data type}. This
covers most data types that are commonly used, but the compiler
won't let you, for example, store a QWidget as a value; instead,
store a QWidget *. A few functions have additional requirements;
@@ -149,17 +154,17 @@
support \c operator==(). These requirements are documented on a
per-function basis.
- Like the other container classes, QVector provides \l{Java-style
- iterators} (QVectorIterator and QMutableVectorIterator) and
- \l{STL-style iterators} (QVector::const_iterator and
- QVector::iterator). In practice, these are rarely used, because
- you can use indexes into the QVector.
+ Like the other container classes, QList provides \l{Java-style
+ iterators} (QListIterator and QMutableVectorIterator) 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.
- In addition to QVector, Qt also provides QVarLengthArray, a very
+ In addition to QList, Qt also provides QVarLengthArray, a very
low-level class with little functionality that is optimized for
speed.
- QVector does \e not support inserting, prepending, appending or replacing
+ QList does \e not support inserting, prepending, appending or replacing
with references to its own values. Doing so will cause your application to
abort with an error message.
@@ -170,13 +175,13 @@
\section1 Maximum size and out-of-memory conditions
- The current version of QVector is limited to just under 2 GB (2^31 bytes)
+ The current version of QList is limited to just under 2 GB (2^31 bytes)
in size. The exact value is architecture-dependent, since it depends on the
overhead required for managing the data block, but is no more than 32
- bytes. The number of elements that can be stored in a QVector is that size
+ bytes. The number of elements that can be stored in a QList is that size
divided by the size of each element.
- In case memory allocation fails, QVector will use the \l Q_CHECK_PTR macro,
+ In case memory allocation fails, QList will use the \l Q_CHECK_PTR macro,
which will throw a \c std::bad_alloc exception if the application is being
compiled with exception support. If exceptions are disabled, then running
out of memory is undefined behavior.
@@ -188,7 +193,7 @@
*/
/*!
- \fn template <typename T> QVector<T> QVector<T>::mid(int pos, int length = -1) const
+ \fn template <typename T> QList<T> QList<T>::mid(int pos, int length = -1) const
Returns a sub-vector which contains elements from this vector,
starting at position \a pos. If \a length is -1 (the default), all
@@ -198,7 +203,7 @@
*/
-/*! \fn template <typename T> QVector<T>::QVector()
+/*! \fn template <typename T> QList<T>::QList()
Constructs an empty vector.
@@ -206,15 +211,15 @@
*/
/*!
- \fn template <typename T> QVector<T>::QVector(QVector<T> &&other)
+ \fn template <typename T> QList<T>::QList(QList<T> &&other)
- Move-constructs a QVector instance, making it point at the same
+ Move-constructs a QList instance, making it point at the same
object that \a other was pointing to.
\since 5.2
*/
-/*! \fn template <typename T> QVector<T>::QVector(int size)
+/*! \fn template <typename T> QList<T>::QList(int size)
Constructs a vector with an initial size of \a size elements.
@@ -224,7 +229,7 @@
\sa resize()
*/
-/*! \fn template <typename T> QVector<T>::QVector(int size, const T &value)
+/*! \fn template <typename T> QList<T>::QList(int size, const T &value)
Constructs a vector with an initial size of \a size elements.
Each element is initialized with \a value.
@@ -232,20 +237,20 @@
\sa resize(), fill()
*/
-/*! \fn template <typename T> QVector<T>::QVector(const QVector<T> &other)
+/*! \fn template <typename T> QList<T>::QList(const QList<T> &other)
Constructs a copy of \a other.
This operation takes \l{Algorithmic Complexity}{constant time},
- because QVector is \l{implicitly shared}. This makes returning
- a QVector from a function very fast. If a shared instance is
+ 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{Algorithmic Complexity}{linear time}.
\sa operator=()
*/
-/*! \fn template <typename T> QVector<T>::QVector(std::initializer_list<T> args)
+/*! \fn template <typename T> QList<T>::QList(std::initializer_list<T> args)
\since 4.8
Constructs a vector from the std::initializer_list given by \a args.
@@ -254,7 +259,7 @@
lists.
*/
-/*! \fn template <typename T> template<typename InputIterator> QVector<T>::QVector(InputIterator first, InputIterator last)
+/*! \fn template <typename T> template<typename InputIterator> QList<T>::QList(InputIterator first, InputIterator last)
\since 5.14
Constructs a vector with the contents in the iterator range [\a first, \a last).
@@ -263,33 +268,33 @@
*/
/*!
- \fn template <typename T> QVector<T>::QVector(QArrayDataPointerRef<T> ref)
+ \fn template <typename T> QList<T>::QList(QArrayDataPointerRef<T> ref)
\internal
*/
-/*! \fn template <typename T> QVector<T>::~QVector()
+/*! \fn template <typename T> QList<T>::~QList()
- Destroys the vector.
+ Destroys the list.
*/
-/*! \fn template <typename T> QVector<T> &QVector<T>::operator=(const QVector<T> &other)
+/*! \fn template <typename T> QList<T> &QList<T>::operator=(const QList<T> &other)
Assigns \a other to this vector and returns a reference to this
vector.
*/
/*!
- \fn template <typename T> QVector<T> &QVector<T>::operator=(QVector<T> &&other)
+ \fn template <typename T> QList<T> &QList<T>::operator=(QList<T> &&other)
- Move-assigns \a other to this QVector instance.
+ Move-assigns \a other to this QList instance.
\since 5.2
*/
/*!
- \fn template <typename T> QVector<T> &QVector<T>::operator=(std::initializer_list<T> args)
+ \fn template <typename T> QList<T> &QList<T>::operator=(std::initializer_list<T> args)
- Assigns the collection of values in \a args to this QVector instance.
+ Assigns the collection of values in \a args to this QList instance.
This operator is only enabled if the compiler supports C++11 initializer
lists.
@@ -297,14 +302,14 @@
\since 5.14
*/
-/*! \fn template <typename T> void QVector<T>::swap(QVector<T> &other)
+/*! \fn template <typename T> void QList<T>::swap(QList<T> &other)
\since 4.8
Swaps vector \a other with this vector. This operation is very fast and
never fails.
*/
-/*! \fn template <typename T> void QVector<T>::swapItemsAt(int i, int j)
+/*! \fn template <typename T> void QList<T>::swapItemsAt(int i, int j)
\since 5.14
Exchange the item at index position \a i with the item at index
@@ -314,7 +319,7 @@
*/
-/*! \fn template <typename T> bool QVector<T>::operator==(const QVector<T> &other) const
+/*! \fn template <typename T> bool QList<T>::operator==(const QList<T> &other) const
Returns \c true if \a other is equal to this vector; otherwise
returns \c false.
@@ -328,7 +333,7 @@
\sa operator!=()
*/
-/*! \fn template <typename T> bool QVector<T>::operator!=(const QVector<T> &other) const
+/*! \fn template <typename T> bool QList<T>::operator!=(const QList<T> &other) const
Returns \c true if \a other is not equal to this vector; otherwise
returns \c false.
@@ -342,9 +347,9 @@
\sa operator==()
*/
-/*! \fn template <typename T> bool operator<(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator<(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
- \relates QVector
+ \relates QList
Returns \c true if vector \a lhs is
\l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
@@ -354,9 +359,9 @@
of \c operator<().
*/
-/*! \fn template <typename T> bool operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator<=(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
- \relates QVector
+ \relates QList
Returns \c true if vector \a lhs is
\l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
@@ -366,9 +371,9 @@
of \c operator<().
*/
-/*! \fn template <typename T> bool operator>(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator>(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
- \relates QVector
+ \relates QList
Returns \c true if vector \a lhs is
\l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
@@ -378,9 +383,9 @@
of \c operator<().
*/
-/*! \fn template <typename T> bool operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
+/*! \fn template <typename T> bool operator>=(const QList<T> &lhs, const QList<T> &rhs)
\since 5.6
- \relates QVector
+ \relates QList
Returns \c true if vector \a lhs is
\l{http://en.cppreference.com/w/cpp/algorithm/lexicographical_compare}
@@ -391,9 +396,9 @@
*/
/*!
- \fn template <typename T> size_t qHash(const QVector<T> &key, size_t seed = 0)
+ \fn template <typename T> size_t qHash(const QList<T> &key, size_t seed = 0)
\since 5.6
- \relates QVector
+ \relates QList
Returns the hash value for \a key,
using \a seed to seed the calculation.
@@ -401,21 +406,21 @@
This function requires qHash() to be overloaded for the value type \c T.
*/
-/*! \fn template <typename T> int QVector<T>::size() const
+/*! \fn template <typename T> int QList<T>::size() const
Returns the number of items in the vector.
\sa isEmpty(), resize()
*/
-/*! \fn template <typename T> bool QVector<T>::isEmpty() const
+/*! \fn template <typename T> bool QList<T>::isEmpty() const
Returns \c true if the vector has size 0; otherwise returns \c false.
\sa size(), resize()
*/
-/*! \fn template <typename T> void QVector<T>::resize(int size)
+/*! \fn template <typename T> void QList<T>::resize(int size)
Sets the size of the vector to \a size. If \a size is greater than the
current size, elements are added to the end; the new elements are
@@ -428,13 +433,13 @@
\sa size()
*/
-/*! \fn template <typename T> int QVector<T>::capacity() const
+/*! \fn template <typename T> int QList<T>::capacity() const
Returns the maximum number of items that can be stored in the
vector without forcing a reallocation.
The sole purpose of this function is to provide a means of fine
- tuning QVector's memory usage. In general, you will rarely ever
+ 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().
@@ -444,15 +449,15 @@
\sa reserve(), squeeze()
*/
-/*! \fn template <typename T> void QVector<T>::reserve(int size)
+/*! \fn template <typename T> void QList<T>::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
function to prevent reallocations and memory fragmentation.
If \a size is an underestimate, the worst that will happen is that
- the QVector will be a bit slower. If \a size is an overestimate, you
- may have used more memory than the normal QVector growth strategy
+ the QList will be a bit slower. If \a size is an overestimate, you
+ may have used more memory than the normal QList growth strategy
would have allocated—or you may have used less.
An alternative to reserve() is calling resize(). Whether or not that is
@@ -469,44 +474,44 @@
\sa squeeze(), capacity()
*/
-/*! \fn template <typename T> void QVector<T>::squeeze()
+/*! \fn template <typename T> void QList<T>::squeeze()
Releases any memory not required to store the items.
The sole purpose of this function is to provide a means of fine
- tuning QVector's memory usage. In general, you will rarely ever
+ tuning QList's memory usage. In general, you will rarely ever
need to call this function.
\sa reserve(), capacity()
*/
-/*! \fn template <typename T> void QVector<T>::detach()
+/*! \fn template <typename T> void QList<T>::detach()
\internal
*/
-/*! \fn template <typename T> bool QVector<T>::isDetached() const
+/*! \fn template <typename T> bool QList<T>::isDetached() const
\internal
*/
-/*! \fn template <typename T> void QVector<T>::setSharable(bool sharable)
+/*! \fn template <typename T> void QList<T>::setSharable(bool sharable)
\internal
*/
-/*! \fn template <typename T> bool QVector<T>::isSharedWith(const QVector<T> &other) const
+/*! \fn template <typename T> bool QList<T>::isSharedWith(const QList<T> &other) const
\internal
*/
-/*! \fn template <typename T> T *QVector<T>::data()
+/*! \fn template <typename T> T *QList<T>::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.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 6
+ \snippet code/src_corelib_tools_qlist.cpp 6
The pointer remains valid as long as the vector isn't
reallocated.
@@ -517,12 +522,12 @@
\sa constData(), operator[]()
*/
-/*! \fn template <typename T> const T *QVector<T>::data() const
+/*! \fn template <typename T> const T *QList<T>::data() const
\overload
*/
-/*! \fn template <typename T> const T *QVector<T>::constData() const
+/*! \fn template <typename T> const T *QList<T>::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.
@@ -535,7 +540,7 @@
\sa data(), operator[]()
*/
-/*! \fn template <typename T> void QVector<T>::clear()
+/*! \fn template <typename T> void QList<T>::clear()
Removes all the elements from the vector.
@@ -543,8 +548,8 @@
the vector. From Qt 5.7, the capacity is preserved. To shed
all capacity, swap with a default-constructed vector:
\code
- QVector<T> v ...;
- QVector<T>().swap(v);
+ QList<T> v ...;
+ QList<T>().swap(v);
Q_ASSERT(v.capacity() == 0);
\endcode
or call squeeze().
@@ -552,7 +557,7 @@
\sa squeeze()
*/
-/*! \fn template <typename T> const T &QVector<T>::at(int i) const
+/*! \fn template <typename T> const T &QList<T>::at(int i) const
Returns the item at index position \a i in the vector.
@@ -562,20 +567,20 @@
\sa value(), operator[]()
*/
-/*! \fn template <typename T> T &QVector<T>::operator[](int i)
+/*! \fn template <typename T> T &QList<T>::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 vector (i.e., 0 <= \a i
< size()).
- Note that using non-const operators can cause QVector to do a deep
+ Note that using non-const operators can cause QList to do a deep
copy.
\sa at(), value()
*/
-/*! \fn template <typename T> const T &QVector<T>::operator[](int i) const
+/*! \fn template <typename T> const T &QList<T>::operator[](int i) const
\overload
@@ -583,17 +588,17 @@
*/
/*!
- \fn template <typename T> void QVector<T>::append(const T &value)
+ \fn template <typename T> void QList<T>::append(const T &value)
Inserts \a value at the end of the vector.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 7
+ \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.
- This operation is relatively fast, because QVector typically
+ This operation is relatively fast, because QList typically
allocates more memory than necessary, so it can grow without
reallocating the entire vector each time.
@@ -601,16 +606,16 @@
*/
/*!
- \fn template <typename T> void QVector<T>::append(T &&value)
+ \fn template <typename T> void QList<T>::append(T &&value)
\since 5.6
\overload
Example:
- \snippet code/src_corelib_tools_qvector.cpp move-append
+ \snippet code/src_corelib_tools_qlist.cpp move-append
*/
-/*! \fn template <typename T> void QVector<T>::append(const QVector<T> &value)
+/*! \fn template <typename T> void QList<T>::append(const QList<T> &value)
\overload
@@ -623,13 +628,13 @@
/*!
- \fn template <typename T> void QVector<T>::prepend(const T &value)
- \fn template <typename T> void QVector<T>::prepend(T &&value)
+ \fn template <typename T> void QList<T>::prepend(const T &value)
+ \fn template <typename T> void QList<T>::prepend(T &&value)
Inserts \a value at the beginning of the vector.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 8
+ \snippet code/src_corelib_tools_qlist.cpp 8
This is the same as vector.insert(0, \a value).
@@ -643,8 +648,8 @@
*/
/*!
- \fn template <typename T> template <typename ...Args> T &QVector<T>::emplaceBack(Args&&... args)
- \fn template <typename T> template <typename ...Args> T &QVector<T>::emplace_back(Args&&... args)
+ \fn template <typename T> template <typename ...Args> T &QList<T>::emplaceBack(Args&&... args)
+ \fn template <typename T> template <typename ...Args> T &QList<T>::emplace_back(Args&&... args)
Adds a new element to the end for the container. This new element
is constructed in-place using \a args as the arguments for its
@@ -653,26 +658,26 @@
Returns a reference to the new element.
Example:
- \snippet code/src_corelib_tools_qvector.cpp emplace-back
+ \snippet code/src_corelib_tools_qlist.cpp emplace-back
It is also possible to access a newly created object by using
returned reference:
- \snippet code/src_corelib_tools_qvector.cpp emplace-back-ref
+ \snippet code/src_corelib_tools_qlist.cpp emplace-back-ref
This is the same as vector.emplace(vector.size(), \a args).
\sa emplace
*/
-/*! \fn template <typename T> void QVector<T>::insert(int i, const T &value)
- \fn template <typename T> void QVector<T>::insert(int i, T &&value)
+/*! \fn template <typename T> void QList<T>::insert(int i, const T &value)
+ \fn template <typename T> void QList<T>::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.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 9
+ \snippet code/src_corelib_tools_qlist.cpp 9
For large vectors, this operation can be slow (\l{linear time}),
because it requires moving all the items at indexes \a i and
@@ -683,7 +688,7 @@
\sa append(), prepend(), remove()
*/
-/*! \fn template <typename T> void QVector<T>::insert(int i, int count, const T &value)
+/*! \fn template <typename T> void QList<T>::insert(int i, int count, const T &value)
\overload
@@ -691,12 +696,12 @@
vector.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 10
+ \snippet code/src_corelib_tools_qlist.cpp 10
*/
/*!
- \fn template <typename T> QVector<T>::iterator QVector<T>::insert(iterator before, const T &value)
- \fn template <typename T> QVector<T>::iterator QVector<T>::insert(iterator before, T &&value)
+ \fn template <typename T> QList<T>::iterator QList<T>::insert(iterator before, const T &value)
+ \fn template <typename T> QList<T>::iterator QList<T>::insert(iterator before, T &&value)
\overload
@@ -704,7 +709,7 @@
\a before. Returns an iterator pointing at the inserted item.
*/
-/*! \fn template <typename T> QVector<T>::iterator QVector<T>::insert(iterator before, int count, const T &value)
+/*! \fn template <typename T> QList<T>::iterator QList<T>::insert(iterator before, int count, const T &value)
Inserts \a count copies of \a value in front of the item pointed to
by the iterator \a before. Returns an iterator pointing at the
@@ -712,7 +717,7 @@
*/
/*!
- \fn template <typename T> template <typename ...Args> QVector<T>::iterator QVector<T>::emplace(int i, Args&&... args)
+ \fn template <typename T> template <typename ...Args> QList<T>::iterator QList<T>::emplace(int i, Args&&... args)
Extends the container by inserting a new element at position \a i.
This new element is constructed in-place using \a args as the
@@ -721,7 +726,7 @@
Returns an iterator to the new element.
Example:
- \snippet code/src_corelib_tools_qvector.cpp emplace
+ \snippet code/src_corelib_tools_qlist.cpp emplace
\note It is garanteed that the element will be created in place
at the beginning, but after that it might be copied or
@@ -731,7 +736,7 @@
*/
-/*! \fn template <typename T> void QVector<T>::replace(int i, const T &value)
+/*! \fn template <typename T> void QList<T>::replace(int i, const T &value)
Replaces the item at index position \a i with \a value.
@@ -741,7 +746,7 @@
\sa operator[](), remove()
*/
-/*! \fn template <typename T> void QVector<T>::remove(int i)
+/*! \fn template <typename T> void QList<T>::remove(int i)
\overload
@@ -750,7 +755,7 @@
\sa insert(), replace(), fill()
*/
-/*! \fn template <typename T> void QVector<T>::remove(int i, int count)
+/*! \fn template <typename T> void QList<T>::remove(int i, int count)
\overload
@@ -760,7 +765,7 @@
\sa insert(), replace(), fill()
*/
-/*! \fn template <typename T> void QVector<T>::removeAt(int i)
+/*! \fn template <typename T> void QList<T>::removeAt(int i)
\since 5.2
Removes the element at index position \a i.
@@ -774,7 +779,7 @@
\sa remove(), QList::removeAt()
*/
-/*! \fn template <typename T> int QVector<T>::removeAll(const T &t)
+/*! \fn template <typename T> int QList<T>::removeAll(const T &t)
\since 5.4
Removes all elements that compare equal to \a t from the
@@ -785,7 +790,7 @@
\sa removeOne(), QList::removeAll()
*/
-/*! \fn template <typename T> bool QVector<T>::removeOne(const T &t)
+/*! \fn template <typename T> bool QList<T>::removeOne(const T &t)
\since 5.4
Removes the first element that compares equal to \a t from the
@@ -796,7 +801,7 @@
\sa removeAll(), QList::removeOne()
*/
-/*! \fn template <typename T> int QVector<T>::length() const
+/*! \fn template <typename T> int QList<T>::length() const
\since 5.2
Same as size() and count().
@@ -806,7 +811,7 @@
\sa size(), count(), QList::length()
*/
-/*! \fn template <typename T> T QVector<T>::takeAt(int i)
+/*! \fn template <typename T> T QList<T>::takeAt(int i)
\since 5.2
Removes the element at index position \a i and returns it.
@@ -823,7 +828,7 @@
\sa takeFirst(), takeLast(), QList::takeAt()
*/
-/*! \fn template <typename T> void QVector<T>::move(int from, int to)
+/*! \fn template <typename T> void QList<T>::move(int from, int to)
\since 5.6
Moves the item at index position \a from to index position \a to.
@@ -833,7 +838,7 @@
\sa QList::move()
*/
-/*! \fn template <typename T> void QVector<T>::removeFirst()
+/*! \fn template <typename T> void QList<T>::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
@@ -843,7 +848,7 @@
\sa remove(), takeFirst(), isEmpty()
*/
-/*! \fn template <typename T> void QVector<T>::removeLast()
+/*! \fn template <typename T> void QList<T>::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
@@ -853,7 +858,7 @@
\sa remove(), takeLast(), removeFirst(), isEmpty()
*/
-/*! \fn template <typename T> T QVector<T>::takeFirst()
+/*! \fn template <typename T> T QList<T>::takeFirst()
\since 5.1
Removes the first item in the vector and returns it. This function
@@ -863,7 +868,7 @@
\sa takeLast(), removeFirst()
*/
-/*! \fn template <typename T> T QVector<T>::takeLast()
+/*! \fn template <typename T> T QList<T>::takeLast()
\since 5.1
Removes the last item in the list and returns it. This function
@@ -877,7 +882,7 @@
*/
/*!
- \fn template <typename T> template <typename ...Args> QVector<T>::iterator QVector<T>::emplace(QVector<T>::iterator before, Args&&... args)
+ \fn template <typename T> template <typename ...Args> QList<T>::iterator QList<T>::emplace(QList<T>::iterator before, Args&&... args)
\overload
@@ -888,26 +893,26 @@
Returns an iterator to the new element.
*/
-/*! \fn template <typename T> QVector<T> &QVector<T>::fill(const T &value, int size = -1)
+/*! \fn template <typename T> QList<T> &QList<T>::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
size beforehand.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 11
+ \snippet code/src_corelib_tools_qlist.cpp 11
\sa resize()
*/
-/*! \fn template <typename T> int QVector<T>::indexOf(const T &value, int from = 0) const
+/*! \fn template <typename T> int QList<T>::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.
Returns -1 if no item matched.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 12
+ \snippet code/src_corelib_tools_qlist.cpp 12
This function requires the value type to have an implementation of
\c operator==().
@@ -915,7 +920,7 @@
\sa lastIndexOf(), contains()
*/
-/*! \fn template <typename T> int QVector<T>::lastIndexOf(const T &value, int from = -1) const
+/*! \fn template <typename T> int QList<T>::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
@@ -923,7 +928,7 @@
last item. Returns -1 if no item matched.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 13
+ \snippet code/src_corelib_tools_qlist.cpp 13
This function requires the value type to have an implementation of
\c operator==().
@@ -931,7 +936,7 @@
\sa indexOf()
*/
-/*! \fn template <typename T> bool QVector<T>::contains(const T &value) const
+/*! \fn template <typename T> bool QList<T>::contains(const T &value) const
Returns \c true if the vector contains an occurrence of \a value;
otherwise returns \c false.
@@ -942,7 +947,7 @@
\sa indexOf(), count()
*/
-/*! \fn template <typename T> bool QVector<T>::startsWith(const T &value) const
+/*! \fn template <typename T> bool QList<T>::startsWith(const T &value) const
\since 4.5
Returns \c true if this vector is not empty and its first
@@ -951,7 +956,7 @@
\sa isEmpty(), first()
*/
-/*! \fn template <typename T> bool QVector<T>::endsWith(const T &value) const
+/*! \fn template <typename T> bool QList<T>::endsWith(const T &value) const
\since 4.5
Returns \c true if this vector is not empty and its last
@@ -961,7 +966,7 @@
*/
-/*! \fn template <typename T> int QVector<T>::count(const T &value) const
+/*! \fn template <typename T> int QList<T>::count(const T &value) const
Returns the number of occurrences of \a value in the vector.
@@ -971,14 +976,14 @@
\sa contains(), indexOf()
*/
-/*! \fn template <typename T> int QVector<T>::count() const
+/*! \fn template <typename T> int QList<T>::count() const
\overload
Same as size().
*/
-/*! \fn template <typename T> QVector<T>::iterator QVector<T>::begin()
+/*! \fn template <typename T> QList<T>::iterator QList<T>::begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in
the vector.
@@ -986,12 +991,12 @@
\sa constBegin(), end()
*/
-/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::begin() const
+/*! \fn template <typename T> QList<T>::const_iterator QList<T>::begin() const
\overload
*/
-/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::cbegin() const
+/*! \fn template <typename T> QList<T>::const_iterator QList<T>::cbegin() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
@@ -1000,7 +1005,7 @@
\sa begin(), cend()
*/
-/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::constBegin() const
+/*! \fn template <typename T> QList<T>::const_iterator QList<T>::constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item
in the vector.
@@ -1008,7 +1013,7 @@
\sa begin(), constEnd()
*/
-/*! \fn template <typename T> QVector<T>::iterator QVector<T>::end()
+/*! \fn template <typename T> QList<T>::iterator QList<T>::end()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item
after the last item in the vector.
@@ -1016,12 +1021,12 @@
\sa begin(), constEnd()
*/
-/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::end() const
+/*! \fn template <typename T> QList<T>::const_iterator QList<T>::end() const
\overload
*/
-/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::cend() const
+/*! \fn template <typename T> QList<T>::const_iterator QList<T>::cend() const
\since 5.0
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
@@ -1030,7 +1035,7 @@
\sa cbegin(), end()
*/
-/*! \fn template <typename T> QVector<T>::const_iterator QVector<T>::constEnd() const
+/*! \fn template <typename T> QList<T>::const_iterator QList<T>::constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary
item after the last item in the vector.
@@ -1038,7 +1043,7 @@
\sa constBegin(), end()
*/
-/*! \fn template <typename T> QVector<T>::reverse_iterator QVector<T>::rbegin()
+/*! \fn template <typename T> QList<T>::reverse_iterator QList<T>::rbegin()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -1047,12 +1052,12 @@
\sa begin(), crbegin(), rend()
*/
-/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::rbegin() const
+/*! \fn template <typename T> QList<T>::const_reverse_iterator QList<T>::rbegin() const
\since 5.6
\overload
*/
-/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::crbegin() const
+/*! \fn template <typename T> QList<T>::const_reverse_iterator QList<T>::crbegin() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to the first
@@ -1061,7 +1066,7 @@
\sa begin(), rbegin(), rend()
*/
-/*! \fn template <typename T> QVector<T>::reverse_iterator QVector<T>::rend()
+/*! \fn template <typename T> QList<T>::reverse_iterator QList<T>::rend()
\since 5.6
Returns a \l{STL-style iterators}{STL-style} reverse iterator pointing to one past
@@ -1070,12 +1075,12 @@
\sa end(), crend(), rbegin()
*/
-/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::rend() const
+/*! \fn template <typename T> QList<T>::const_reverse_iterator QList<T>::rend() const
\since 5.6
\overload
*/
-/*! \fn template <typename T> QVector<T>::const_reverse_iterator QVector<T>::crend() const
+/*! \fn template <typename T> QList<T>::const_reverse_iterator QList<T>::crend() const
\since 5.6
Returns a const \l{STL-style iterators}{STL-style} reverse iterator pointing to one
@@ -1084,7 +1089,7 @@
\sa end(), rend(), rbegin()
*/
-/*! \fn template <typename T> QVector<T>::iterator QVector<T>::erase(iterator pos)
+/*! \fn template <typename T> QList<T>::iterator QList<T>::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
@@ -1093,7 +1098,7 @@
\sa insert(), remove()
*/
-/*! \fn template <typename T> QVector<T>::iterator QVector<T>::erase(iterator begin, iterator end)
+/*! \fn template <typename T> QList<T>::iterator QList<T>::erase(iterator begin, iterator end)
\overload
@@ -1102,7 +1107,7 @@
before the call.
*/
-/*! \fn template <typename T> T& QVector<T>::first()
+/*! \fn template <typename T> T& QList<T>::first()
Returns a reference to the first item in the vector. This
function assumes that the vector isn't empty.
@@ -1110,12 +1115,12 @@
\sa last(), isEmpty(), constFirst()
*/
-/*! \fn template <typename T> const T& QVector<T>::first() const
+/*! \fn template <typename T> const T& QList<T>::first() const
\overload
*/
-/*! \fn template <typename T> const T& QVector<T>::constFirst() const
+/*! \fn template <typename T> const T& QList<T>::constFirst() const
\since 5.6
Returns a const reference to the first item in the vector. This
@@ -1124,7 +1129,7 @@
\sa constLast(), isEmpty(), first()
*/
-/*! \fn template <typename T> T& QVector<T>::last()
+/*! \fn template <typename T> T& QList<T>::last()
Returns a reference to the last item in the vector. This function
assumes that the vector isn't empty.
@@ -1132,12 +1137,12 @@
\sa first(), isEmpty(), constLast()
*/
-/*! \fn template <typename T> const T& QVector<T>::last() const
+/*! \fn template <typename T> const T& QList<T>::last() const
\overload
*/
-/*! \fn template <typename T> const T& QVector<T>::constLast() const
+/*! \fn template <typename T> const T& QList<T>::constLast() const
\since 5.6
Returns a const reference to the last item in the vector. This function
@@ -1146,7 +1151,7 @@
\sa constFirst(), isEmpty(), last()
*/
-/*! \fn template <typename T> T QVector<T>::value(int i) const
+/*! \fn template <typename T> T QList<T>::value(int i) const
Returns the value at index position \a i in the vector.
@@ -1158,7 +1163,7 @@
\sa at(), operator[]()
*/
-/*! \fn template <typename T> T QVector<T>::value(int i, const T &defaultValue) const
+/*! \fn template <typename T> T QList<T>::value(int i, const T &defaultValue) const
\overload
@@ -1166,74 +1171,74 @@
\a defaultValue.
*/
-/*! \fn template <typename T> void QVector<T>::push_back(const T &value)
+/*! \fn template <typename T> void QList<T>::push_back(const T &value)
This function is provided for STL compatibility. It is equivalent
to append(\a value).
*/
-/*! \fn template <typename T> void QVector<T>::push_back(T &&value)
+/*! \fn template <typename T> void QList<T>::push_back(T &&value)
\since 5.6
\overload
*/
/*!
- \fn template <typename T> void QVector<T>::push_front(const T &value)
- \fn template <typename T> void QVector<T>::push_front(T &&value)
+ \fn template <typename T> void QList<T>::push_front(const T &value)
+ \fn template <typename T> void QList<T>::push_front(T &&value)
This function is provided for STL compatibility. It is equivalent
to prepend(\a value).
*/
-/*! \fn template <typename T> void QVector<T>::pop_front()
+/*! \fn template <typename T> void QList<T>::pop_front()
This function is provided for STL compatibility. It is equivalent
to removeFirst().
*/
-/*! \fn template <typename T> void QVector<T>::pop_back()
+/*! \fn template <typename T> void QList<T>::pop_back()
This function is provided for STL compatibility. It is equivalent
to removeLast().
*/
-/*! \fn template <typename T> T& QVector<T>::front()
+/*! \fn template <typename T> T& QList<T>::front()
This function is provided for STL compatibility. It is equivalent
to first().
*/
-/*! \fn template <typename T> QVector<T>::const_reference QVector<T>::front() const
+/*! \fn template <typename T> QList<T>::const_reference QList<T>::front() const
\overload
*/
-/*! \fn template <typename T> QVector<T>::reference QVector<T>::back()
+/*! \fn template <typename T> QList<T>::reference QList<T>::back()
This function is provided for STL compatibility. It is equivalent
to last().
*/
-/*! \fn template <typename T> QVector<T>::const_reference QVector<T>::back() const
+/*! \fn template <typename T> QList<T>::const_reference QList<T>::back() const
\overload
*/
-/*! \fn template <typename T> void QVector<T>::shrink_to_fit()
+/*! \fn template <typename T> void QList<T>::shrink_to_fit()
\since 5.10
This function is provided for STL compatibility. It is equivalent
to squeeze().
*/
-/*! \fn template <typename T> bool QVector<T>::empty() const
+/*! \fn template <typename T> bool QList<T>::empty() const
This function is provided for STL compatibility. It is equivalent
to isEmpty(), returning \c true if the vector is empty; otherwise
returns \c false.
*/
-/*! \fn template <typename T> QVector<T> &QVector<T>::operator+=(const QVector<T> &other)
+/*! \fn template <typename T> QList<T> &QList<T>::operator+=(const QList<T> &other)
Appends the items of the \a other vector to this vector and
returns a reference to this vector.
@@ -1241,7 +1246,7 @@
\sa operator+(), append()
*/
-/*! \fn template <typename T> void QVector<T>::operator+=(const T &value)
+/*! \fn template <typename T> void QList<T>::operator+=(const T &value)
\overload
@@ -1250,7 +1255,7 @@
\sa append(), operator<<()
*/
-/*! \fn template <typename T> void QVector<T>::operator+=(T &&value)
+/*! \fn template <typename T> void QList<T>::operator+=(T &&value)
\since 5.11
\overload
@@ -1258,7 +1263,7 @@
\sa append(), operator<<()
*/
-/*! \fn template <typename T> QVector<T> QVector<T>::operator+(const QVector<T> &other) const
+/*! \fn template <typename T> QList<T> QList<T>::operator+(const QList<T> &other) const
Returns a vector that contains all the items in this vector
followed by all the items in the \a other vector.
@@ -1266,7 +1271,7 @@
\sa operator+=()
*/
-/*! \fn template <typename T> QVector<T> &QVector<T>::operator<<(const T &value)
+/*! \fn template <typename T> QList<T> &QList<T>::operator<<(const T &value)
Appends \a value to the vector and returns a reference to this
vector.
@@ -1274,7 +1279,7 @@
\sa append(), operator+=()
*/
-/*! \fn template <typename T> QVector<T> &QVector<T>::operator<<(T &&value)
+/*! \fn template <typename T> QList<T> &QList<T>::operator<<(T &&value)
\since 5.11
\overload
@@ -1283,18 +1288,18 @@
*/
-/*! \fn template <typename T> QVector<T> &QVector<T>::operator<<(const QVector<T> &other)
+/*! \fn template <typename T> QList<T> &QList<T>::operator<<(const QList<T> &other)
Appends \a other to the vector and returns a reference to the
vector.
*/
-/*! \typedef QVector::iterator
+/*! \typedef QList::iterator
- The QVector::iterator typedef provides an STL-style non-const
- iterator for QVector and QStack.
+ The QList::iterator typedef provides an STL-style non-const
+ iterator for QList and QStack.
- QVector provides both \l{STL-style iterators} and \l{Java-style
+ QList provides both \l{STL-style iterators} and \l{Java-style
iterators}. The STL-style non-const iterator is simply a typedef
for "T *" (pointer to T).
@@ -1303,15 +1308,15 @@
while iterators are active on that container. For more information,
read \l{Implicit sharing iterator problem}.
- \sa QVector::begin(), QVector::end(), QVector::const_iterator, QMutableVectorIterator
+ \sa QList::begin(), QList::end(), QList::const_iterator, QMutableVectorIterator
*/
-/*! \typedef QVector::const_iterator
+/*! \typedef QList::const_iterator
- The QVector::const_iterator typedef provides an STL-style const
- iterator for QVector and QStack.
+ The QList::const_iterator typedef provides an STL-style const
+ iterator for QList and QStack.
- QVector provides both \l{STL-style iterators} and \l{Java-style
+ QList provides both \l{STL-style iterators} and \l{Java-style
iterators}. The STL-style const iterator is simply a typedef for
"const T *" (pointer to const T).
@@ -1320,14 +1325,14 @@
while iterators are active on that container. For more information,
read \l{Implicit sharing iterator problem}.
- \sa QVector::constBegin(), QVector::constEnd(), QVector::iterator, QVectorIterator
+ \sa QList::constBegin(), QList::constEnd(), QList::iterator, QListIterator
*/
-/*! \typedef QVector::reverse_iterator
+/*! \typedef QList::reverse_iterator
\since 5.6
- The QVector::reverse_iterator typedef provides an STL-style non-const
- reverse iterator for QVector.
+ The QList::reverse_iterator typedef provides an STL-style non-const
+ reverse iterator for QList.
It is simply a typedef for \c{std::reverse_iterator<T*>}.
@@ -1336,14 +1341,14 @@
while iterators are active on that container. For more information,
read \l{Implicit sharing iterator problem}.
- \sa QVector::rbegin(), QVector::rend(), QVector::const_reverse_iterator, QVector::iterator
+ \sa QList::rbegin(), QList::rend(), QList::const_reverse_iterator, QList::iterator
*/
-/*! \typedef QVector::const_reverse_iterator
+/*! \typedef QList::const_reverse_iterator
\since 5.6
- The QVector::const_reverse_iterator typedef provides an STL-style const
- reverse iterator for QVector.
+ The QList::const_reverse_iterator typedef provides an STL-style const
+ reverse iterator for QList.
It is simply a typedef for \c{std::reverse_iterator<const T*>}.
@@ -1352,108 +1357,102 @@
while iterators are active on that container. For more information,
read \l{Implicit sharing iterator problem}.
- \sa QVector::rbegin(), QVector::rend(), QVector::reverse_iterator, QVector::const_iterator
+ \sa QList::rbegin(), QList::rend(), QList::reverse_iterator, QList::const_iterator
*/
-/*! \typedef QVector::Iterator
+/*! \typedef QList::Iterator
- Qt-style synonym for QVector::iterator.
+ Qt-style synonym for QList::iterator.
*/
-/*! \typedef QVector::ConstIterator
+/*! \typedef QList::ConstIterator
- Qt-style synonym for QVector::const_iterator.
+ Qt-style synonym for QList::const_iterator.
*/
-/*! \typedef QVector::const_pointer
+/*! \typedef QList::const_pointer
Typedef for const T *. Provided for STL compatibility.
*/
-/*! \typedef QVector::const_reference
+/*! \typedef QList::const_reference
Typedef for T &. Provided for STL compatibility.
*/
-/*! \typedef QVector::difference_type
+/*! \typedef QList::difference_type
Typedef for ptrdiff_t. Provided for STL compatibility.
*/
-/*! \typedef QVector::pointer
+/*! \typedef QList::pointer
Typedef for T *. Provided for STL compatibility.
*/
-/*! \typedef QVector::reference
+/*! \typedef QList::reference
Typedef for T &. Provided for STL compatibility.
*/
-/*! \typedef QVector::size_type
+/*! \typedef QList::size_type
Typedef for int. Provided for STL compatibility.
*/
-/*! \typedef QVector::value_type
+/*! \typedef QList::value_type
Typedef for T. Provided for STL compatibility.
*/
-/*! \fn template <typename T> QList<T> QVector<T>::toList() const
-
- Returns a QList object with the data contained in this QVector.
-
- Example:
+/*! \fn template <typename T> QList<T> QList<T>::toList() const
+ \fn template <typename T> QList<T> QList<T>::toVector() const
+ \obsolete
- \snippet code/src_corelib_tools_qvector.cpp 14
+ A no-op in Qt 6. Provided for backwards compatibility with
+ Qt 5, where QList and QVector where two different types.
- \include containers-range-constructor.qdocinc
-
- \sa fromList(), QList::fromVector()
+ Returns this list.
*/
-/*! \fn template <typename T> QVector<T> QVector<T>::fromList(const QList<T> &list)
+/*! \fn template <typename T> QList<T> QList<T>::fromList(const QList<T> &list)
+ \fn template <typename T> QList<T> QList<T>::fromVector(const QList<T> &list)
+ \obsolete
- Returns a QVector object with the data contained in \a list.
-
- Example:
-
- \snippet code/src_corelib_tools_qvector.cpp 15
-
- \include containers-range-constructor.qdocinc
+ A no-op in Qt 6. Provided for backwards compatibility with
+ Qt 5, where QList and QVector where two different types.
- \sa toList(), QList::toVector()
+ Returns this list.
*/
-/*! \fn template <typename T> QVector<T> QVector<T>::fromStdVector(const std::vector<T> &vector)
+/*! \fn template <typename T> QList<T> QList<T>::fromStdVector(const std::vector<T> &vector)
- Returns a QVector object with the data contained in \a vector. The
- order of the elements in the QVector is the same as in \a vector.
+ Returns a QList object with the data contained in \a vector. The
+ order of the elements in the QList is the same as in \a vector.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 16
+ \snippet code/src_corelib_tools_qlist.cpp 16
\include containers-range-constructor.qdocinc
\sa toStdVector(), QList::fromStdList()
*/
-/*! \fn template <typename T> std::vector<T> QVector<T>::toStdVector() const
+/*! \fn template <typename T> std::vector<T> QList<T>::toStdVector() const
- Returns a std::vector object with the data contained in this QVector.
+ Returns a std::vector object with the data contained in this QList.
Example:
- \snippet code/src_corelib_tools_qvector.cpp 17
+ \snippet code/src_corelib_tools_qlist.cpp 17
\include containers-range-constructor.qdocinc
\sa fromStdVector(), QList::toStdList()
*/
-/*! \fn template <typename T> QDataStream &operator<<(QDataStream &out, const QVector<T> &vector)
- \relates QVector
+/*! \fn template <typename T> QDataStream &operator<<(QDataStream &out, const QList<T> &vector)
+ \relates QList
Writes the vector \a vector to stream \a out.
@@ -1462,8 +1461,8 @@
\sa{Serializing Qt Data Types}{Format of the QDataStream operators}
*/
-/*! \fn template <typename T> QDataStream &operator>>(QDataStream &in, QVector<T> &vector)
- \relates QVector
+/*! \fn template <typename T> QDataStream &operator>>(QDataStream &in, QList<T> &vector)
+ \relates QList
Reads a vector from stream \a in into \a vector.
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index b502a86442..8d880407dd 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -1,7 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2019 Intel Corporation
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -41,758 +40,18 @@
#ifndef QVECTOR_H
#define QVECTOR_H
-#include <QtCore/qarraydatapointer.h>
-#include <QtCore/qnamespace.h>
-#include <QtCore/qhashfunctions.h>
-#include <QtCore/qiterator.h>
-
-#include <functional>
-#include <limits>
-#include <initializer_list>
-#include <type_traits>
+#include <QtCore/qlist.h>
+#include <QtCore/qcontainerfwd.h>
QT_BEGIN_NAMESPACE
-namespace QtPrivate {
- template <typename V, typename U> int indexOf(const QVector<V> &list, const U &u, int from);
- template <typename V, typename U> int lastIndexOf(const QVector<V> &list, const U &u, int from);
-}
-
-template <typename T> struct QVectorSpecialMethods
-{
-protected:
- ~QVectorSpecialMethods() = default;
-};
-template <> struct QVectorSpecialMethods<QByteArray>;
-template <> struct QVectorSpecialMethods<QString>;
-
-template <typename T>
-class QVector
-#ifndef Q_QDOC
- : public QVectorSpecialMethods<T>
-#endif
-{
- typedef QTypedArrayData<T> Data;
- typedef QArrayDataOps<T> DataOps;
- typedef QArrayDataPointer<T> DataPointer;
- class DisableRValueRefs {};
-
- DataPointer d;
-
- template <typename V, typename U> friend int QtPrivate::indexOf(const QVector<V> &list, const U &u, int from);
- template <typename V, typename U> friend int QtPrivate::lastIndexOf(const QVector<V> &list, const U &u, int from);
-
-public:
- typedef T Type;
- typedef T value_type;
- typedef value_type *pointer;
- typedef const value_type *const_pointer;
- typedef value_type &reference;
- typedef const value_type &const_reference;
- typedef int size_type;
- typedef qptrdiff difference_type;
- typedef typename Data::iterator iterator;
- typedef typename Data::const_iterator const_iterator;
- typedef iterator Iterator;
- typedef const_iterator ConstIterator;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef typename DataPointer::parameter_type parameter_type;
- using rvalue_ref = typename std::conditional<DataPointer::pass_parameter_by_value, DisableRValueRefs, T &&>::type;
-
-private:
- void resize_internal(int i, Qt::Initialization);
- bool isValidIterator(const_iterator i) const
- {
- const std::less<const T*> less = {};
- return !less(d->end(), i) && !less(i, d->begin());
- }
-public:
- QVector(DataPointer dd) noexcept
- : d(dd)
- {
- }
-
-public:
- constexpr inline QVector() noexcept { }
- explicit QVector(int size)
- : d(Data::allocate(size))
- {
- if (size)
- d->appendInitialize(size);
- }
- QVector(int size, const T &t)
- : d(Data::allocate(size))
- {
- if (size)
- d->copyAppend(size, t);
- }
-
- inline QVector(const QVector<T> &other) noexcept : d(other.d) {}
- QVector(QVector<T> &&other) noexcept : d(std::move(other.d)) {}
- inline QVector(std::initializer_list<T> args)
- : d(Data::allocate(args.size()))
- {
- if (args.size())
- d->copyAppend(args.begin(), args.end());
- }
-
- ~QVector() /*noexcept(std::is_nothrow_destructible<T>::value)*/ {}
- QVector<T> &operator=(const QVector<T> &other) { d = other.d; return *this; }
- QVector &operator=(QVector &&other) noexcept(std::is_nothrow_destructible<T>::value)
- {
- d = std::move(other.d);
- return *this;
- }
- QVector<T> &operator=(std::initializer_list<T> args)
- {
- d = DataPointer(Data::allocate(args.size()));
- if (args.size())
- d->copyAppend(args.begin(), args.end());
- return *this;
- }
- template <typename InputIterator, QtPrivate::IfIsForwardIterator<InputIterator> = true>
- QVector(InputIterator i1, InputIterator i2)
- : d(Data::allocate(std::distance(i1, i2)))
- {
- if (std::distance(i1, i2))
- d->copyAppend(i1, i2);
- }
-
- template <typename InputIterator, QtPrivate::IfIsNotForwardIterator<InputIterator> = true>
- QVector(InputIterator i1, InputIterator i2)
- : QVector()
- {
- QtPrivate::reserveIfForwardIterator(this, i1, i2);
- std::copy(i1, i2, std::back_inserter(*this));
- }
-
- void swap(QVector<T> &other) noexcept { qSwap(d, other.d); }
-
- friend bool operator==(const QVector &l, const QVector &r)
- {
- if (l.size() != r.size())
- return false;
- if (l.begin() == r.begin())
- return true;
-
- // do element-by-element comparison
- return l.d->compare(l.begin(), r.begin(), l.size());
- }
- friend bool operator!=(const QVector &l, const QVector &r)
- {
- return !(l == r);
- }
-
- int size() const noexcept { return int(d->size); }
- int count() const noexcept { return size(); }
- int length() const noexcept { return size(); }
-
- inline bool isEmpty() const noexcept { return d->size == 0; }
-
- void resize(int size)
- {
- resize_internal(size, Qt::Uninitialized);
- if (size > this->size())
- d->appendInitialize(size);
- }
- void resize(int size, parameter_type c)
- {
- resize_internal(size, Qt::Uninitialized);
- if (size > this->size())
- d->copyAppend(size - this->size(), c);
- }
-
- inline int capacity() const { return int(d->constAllocatedCapacity()); }
- void reserve(int size);
- inline void squeeze();
-
- void detach() { d.detach(); }
- bool isDetached() const noexcept { return !d->isShared(); }
-
- inline bool isSharedWith(const QVector<T> &other) const { return d == other.d; }
-
- pointer data() { detach(); return d->data(); }
- const_pointer data() const noexcept { return d->data(); }
- const_pointer constData() const noexcept { return d->data(); }
- void clear() {
- if (!size())
- return;
- if (d->needsDetach()) {
- // must allocate memory
- DataPointer detached(Data::allocate(d.allocatedCapacity(), d->detachFlags()));
- d.swap(detached);
- } else {
- d->truncate(0);
- }
- }
-
- const_reference at(int i) const noexcept
- {
- Q_ASSERT_X(size_t(i) < size_t(d->size), "QVector::at", "index out of range");
- return data()[i];
- }
- reference operator[](int i)
- {
- Q_ASSERT_X(size_t(i) < size_t(d->size), "QVector::operator[]", "index out of range");
- detach();
- return data()[i];
- }
- const_reference operator[](int i) const noexcept { return at(i); }
- void append(const_reference t)
- { append(const_iterator(std::addressof(t)), const_iterator(std::addressof(t)) + 1); }
- void append(const_iterator i1, const_iterator i2);
- void append(rvalue_ref t) { emplaceBack(std::move(t)); }
- void append(const QVector<T> &l) { append(l.constBegin(), l.constEnd()); }
- void prepend(rvalue_ref t);
- void prepend(const T &t);
-
- template <typename ...Args>
- reference emplaceBack(Args&&... args) { return *emplace(count(), std::forward<Args>(args)...); }
-
- iterator insert(int i, parameter_type t)
- { return insert(i, 1, t); }
- iterator insert(int i, int n, parameter_type t);
- iterator insert(const_iterator before, parameter_type t)
- {
- Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
- return insert(before, 1, t);
- }
- iterator insert(const_iterator before, int n, parameter_type t)
- {
- Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
- return insert(std::distance(constBegin(), before), n, t);
- }
- iterator insert(const_iterator before, rvalue_ref t)
- {
- Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
- return insert(std::distance(constBegin(), before), std::move(t));
- }
- iterator insert(int i, rvalue_ref t) { return emplace(i, std::move(t)); }
-
- template <typename ...Args>
- iterator emplace(const_iterator before, Args&&... args)
- {
- Q_ASSERT_X(isValidIterator(before), "QVector::emplace", "The specified iterator argument 'before' is invalid");
- return emplace(std::distance(constBegin(), before), std::forward<Args>(args)...);
- }
-
- template <typename ...Args>
- iterator emplace(int i, Args&&... args);
-#if 0
- template< class InputIt >
- iterator insert( const_iterator pos, InputIt first, InputIt last );
- iterator insert( const_iterator pos, std::initializer_list<T> ilist );
-#endif
- void replace(int i, const T &t)
- {
- Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range");
- const T copy(t);
- data()[i] = copy;
- }
- void replace(int i, rvalue_ref t)
- {
- Q_ASSERT_X(i >= 0 && i < d->size, "QVector<T>::replace", "index out of range");
- const T copy(std::move(t));
- data()[i] = std::move(copy);
- }
-
- void remove(int i, int n = 1);
- void removeFirst() { Q_ASSERT(!isEmpty()); remove(0); }
- void removeLast() { Q_ASSERT(!isEmpty()); remove(size() - 1); }
- value_type takeFirst() { Q_ASSERT(!isEmpty()); value_type v = std::move(first()); remove(0); return v; }
- value_type takeLast() { Q_ASSERT(!isEmpty()); value_type v = std::move(last()); remove(size() - 1); return v; }
-
- QVector<T> &fill(parameter_type t, int size = -1);
-
- int indexOf(const T &t, int from = 0) const noexcept;
- int lastIndexOf(const T &t, int from = -1) const noexcept;
- bool contains(const T &t) const noexcept
- {
- return indexOf(t) != -1;
- }
- int count(const T &t) const noexcept
- {
- return int(std::count(&*cbegin(), &*cend(), t));
- }
-
- // QList compatibility
- void removeAt(int i) { remove(i); }
- int removeAll(const T &t)
- {
- const const_iterator ce = this->cend(), cit = std::find(this->cbegin(), ce, t);
- if (cit == ce)
- return 0;
- int index = cit - this->cbegin();
- // next operation detaches, so ce, cit, t may become invalidated:
- const T tCopy = t;
- const iterator e = end(), it = std::remove(begin() + index, e, tCopy);
- const int result = std::distance(it, e);
- erase(it, e);
- return result;
- }
- bool removeOne(const T &t)
- {
- const int i = indexOf(t);
- if (i < 0)
- return false;
- remove(i);
- return true;
- }
- T takeAt(int i) { T t = std::move((*this)[i]); remove(i); return t; }
- void move(int from, int to)
- {
- Q_ASSERT_X(from >= 0 && from < size(), "QVector::move(int,int)", "'from' is out-of-range");
- Q_ASSERT_X(to >= 0 && to < size(), "QVector::move(int,int)", "'to' is out-of-range");
- if (from == to) // don't detach when no-op
- return;
- detach();
- T * const b = d->begin();
- if (from < to)
- std::rotate(b + from, b + from + 1, b + to + 1);
- else
- std::rotate(b + to, b + from, b + from + 1);
- }
-
- // STL-style
- iterator begin() { detach(); return d->begin(); }
- iterator end() { detach(); return d->end(); }
-
- const_iterator begin() const noexcept { return d->constBegin(); }
- const_iterator end() const noexcept { return d->constEnd(); }
- const_iterator cbegin() const noexcept { return d->constBegin(); }
- const_iterator cend() const noexcept { return d->constEnd(); }
- const_iterator constBegin() const noexcept { return d->constBegin(); }
- const_iterator constEnd() const noexcept { return d->constEnd(); }
- reverse_iterator rbegin() { return reverse_iterator(end()); }
- reverse_iterator rend() { return reverse_iterator(begin()); }
- const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
- const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
- const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
- const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
-
- iterator erase(const_iterator begin, const_iterator end);
- inline iterator erase(const_iterator pos) { return erase(pos, pos+1); }
-
- // more Qt
- inline T& first() { Q_ASSERT(!isEmpty()); return *begin(); }
- inline const T &first() const { Q_ASSERT(!isEmpty()); return *begin(); }
- inline const T &constFirst() const { Q_ASSERT(!isEmpty()); return *begin(); }
- inline T& last() { Q_ASSERT(!isEmpty()); return *(end()-1); }
- inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
- inline const T &constLast() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
- inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
- inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
- QVector<T> mid(int pos, int len = -1) const;
-
- T value(int i) const { return value(i, T()); }
- T value(int i, const T &defaultValue) const;
-
- void swapItemsAt(int i, int j) {
- Q_ASSERT_X(i >= 0 && i < size() && j >= 0 && j < size(),
- "QVector<T>::swap", "index out of range");
- detach();
- qSwap(d->begin()[i], d->begin()[j]);
- }
-
- // STL compatibility
- inline void push_back(const T &t) { append(t); }
- void push_back(rvalue_ref t) { append(std::move(t)); }
- void push_front(rvalue_ref t) { prepend(std::move(t)); }
- inline void push_front(const T &t) { prepend(t); }
- void pop_back() { removeLast(); }
- void pop_front() { removeFirst(); }
-
- template <typename ...Args>
- reference emplace_back(Args&&... args) { return emplaceBack(std::forward<Args>(args)...); }
-
- inline bool empty() const
- { return d->size == 0; }
- inline reference front() { return first(); }
- inline const_reference front() const { return first(); }
- inline reference back() { return last(); }
- inline const_reference back() const { return last(); }
- void shrink_to_fit() { squeeze(); }
-
- // comfort
- QVector<T> &operator+=(const QVector<T> &l) { append(l.cbegin(), l.cend()); return *this; }
- inline QVector<T> operator+(const QVector<T> &l) const
- { QVector n = *this; n += l; return n; }
- inline QVector<T> &operator+=(const T &t)
- { append(t); return *this; }
- inline QVector<T> &operator<< (const T &t)
- { append(t); return *this; }
- inline QVector<T> &operator<<(const QVector<T> &l)
- { *this += l; return *this; }
- inline QVector<T> &operator+=(rvalue_ref t)
- { append(std::move(t)); return *this; }
- inline QVector<T> &operator<<(rvalue_ref t)
- { append(std::move(t)); return *this; }
-
- // Consider deprecating in 6.4 or later
- static QVector<T> fromList(const QVector<T> &list) { return list; }
- QVector<T> toList() const { return *this; }
-
- static inline QVector<T> fromVector(const QVector<T> &vector) { return vector; }
- inline QVector<T> toVector() const { return *this; }
-};
-
-#if defined(__cpp_deduction_guides) && __cpp_deduction_guides >= 201606
-template <typename InputIterator,
- typename ValueType = typename std::iterator_traits<InputIterator>::value_type,
- QtPrivate::IfIsInputIterator<InputIterator> = true>
-QVector(InputIterator, InputIterator) -> QVector<ValueType>;
-#endif
-
-template <typename T>
-inline void QVector<T>::resize_internal(int newSize, Qt::Initialization)
-{
- Q_ASSERT(newSize >= 0);
-
- if (d->needsDetach() || newSize > capacity()) {
- // must allocate memory
- DataPointer detached(Data::allocate(d->detachCapacity(newSize),
- d->detachFlags()));
- if (size() && newSize) {
- detached->copyAppend(constBegin(), constBegin() + qMin(newSize, size()));
- }
- d.swap(detached);
- }
-
- if (newSize < size())
- d->truncate(newSize);
-}
-
-template <typename T>
-void QVector<T>::reserve(int asize)
-{
- // capacity() == 0 for immutable data, so this will force a detaching below
- if (asize <= capacity()) {
- if (d->flags() & Data::CapacityReserved)
- return; // already reserved, don't shrink
- if (!d->isShared()) {
- // accept current allocation, don't shrink
- d->flags() |= Data::CapacityReserved;
- return;
- }
- }
-
- DataPointer detached(Data::allocate(qMax(asize, size()),
- d->detachFlags() | Data::CapacityReserved));
- detached->copyAppend(constBegin(), constEnd());
- d.swap(detached);
-}
-
-template <typename T>
-inline void QVector<T>::squeeze()
-{
- if (d->needsDetach() || size() != capacity()) {
- // must allocate memory
- DataPointer detached(Data::allocate(size(), d->detachFlags() & ~Data::CapacityReserved));
- if (size()) {
- detached->copyAppend(constBegin(), constEnd());
- }
- d.swap(detached);
- }
-}
-
-template <typename T>
-inline void QVector<T>::remove(int i, int n)
-{
- Q_ASSERT_X(size_t(i) + size_t(n) <= size_t(d->size), "QVector::remove", "index out of range");
- Q_ASSERT_X(n >= 0, "QVector::remove", "invalid count");
-
- if (n == 0)
- return;
-
- const size_t newSize = size() - n;
- if (d->needsDetach() ||
- ((d->flags() & Data::CapacityReserved) == 0
- && newSize < d->allocatedCapacity()/2)) {
- // allocate memory
- DataPointer detached(Data::allocate(d->detachCapacity(newSize),
- d->detachFlags() & ~(Data::GrowsBackwards | Data::GrowsForward)));
- const_iterator where = constBegin() + i;
- if (newSize) {
- detached->copyAppend(constBegin(), where);
- detached->copyAppend(where + n, constEnd());
- }
- d.swap(detached);
- } else {
- // we're detached and we can just move data around
- d->erase(d->begin() + i, d->begin() + i + n);
- }
-}
-
-template <typename T>
-inline void QVector<T>::prepend(const T &t)
-{ insert(0, 1, t); }
-template <typename T>
-void QVector<T>::prepend(rvalue_ref t)
-{ insert(0, std::move(t)); }
-
+#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
template<typename T>
-inline T QVector<T>::value(int i, const T &defaultValue) const
-{
- return size_t(i) < size_t(d->size) ? at(i) : defaultValue;
-}
-
-template <typename T>
-inline void QVector<T>::append(const_iterator i1, const_iterator i2)
-{
- if (i1 == i2)
- return;
- const size_t newSize = size() + std::distance(i1, i2);
- if (d->needsDetach() || newSize > d->allocatedCapacity()) {
- DataPointer detached(Data::allocate(d->detachCapacity(newSize),
- d->detachFlags() | Data::GrowsForward));
- detached->copyAppend(constBegin(), constEnd());
- detached->copyAppend(i1, i2);
- d.swap(detached);
- } else {
- // we're detached and we can just move data around
- d->copyAppend(i1, i2);
- }
-}
-
-template <typename T>
-inline typename QVector<T>::iterator
-QVector<T>::insert(int i, int n, parameter_type t)
-{
- Q_ASSERT_X(size_t(i) <= size_t(d->size), "QVector<T>::insert", "index out of range");
-
- // we don't have a quick exit for n == 0
- // it's not worth wasting CPU cycles for that
-
- const size_t newSize = size() + n;
- if (d->needsDetach() || newSize > d->allocatedCapacity()) {
- typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
- if (size_t(i) <= newSize / 4)
- flags |= Data::GrowsBackwards;
-
- DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
- const_iterator where = constBegin() + i;
- detached->copyAppend(constBegin(), where);
- detached->copyAppend(n, t);
- detached->copyAppend(where, constEnd());
- d.swap(detached);
- } else {
- // we're detached and we can just move data around
- if (i == size()) {
- d->copyAppend(n, t);
- } else {
- T copy(t);
- d->insert(d.begin() + i, n, copy);
- }
- }
- return d.begin() + i;
-}
-
-template <typename T>
-template <typename ...Args>
-typename QVector<T>::iterator
-QVector<T>::emplace(int i, Args&&... args)
-{
- Q_ASSERT_X(i >= 0 && i <= d->size, "QVector<T>::insert", "index out of range");
-
- const size_t newSize = size() + 1;
- if (d->needsDetach() || newSize > d->allocatedCapacity()) {
- typename Data::ArrayOptions flags = d->detachFlags() | Data::GrowsForward;
- if (size_t(i) <= newSize / 4)
- flags |= Data::GrowsBackwards;
-
- DataPointer detached(Data::allocate(d->detachCapacity(newSize), flags));
- const_iterator where = constBegin() + i;
-
- // First, create an element to handle cases, when a user moves
- // the element from a container to the same container
- detached->createInPlace(detached.begin() + i, std::forward<Args>(args)...);
-
- // Then, put the first part of the elements to the new location
- detached->copyAppend(constBegin(), where);
-
- // After that, increase the actual size, because we created
- // one extra element
- ++detached.size;
-
- // Finally, put the rest of the elements to the new location
- detached->copyAppend(where, constEnd());
-
- d.swap(detached);
- } else {
- d->emplace(d.begin() + i, std::forward<Args>(args)...);
- }
- return d.begin() + i;
-}
-
-template <typename T>
-typename QVector<T>::iterator QVector<T>::erase(const_iterator abegin, const_iterator aend)
-{
- Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid");
- Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid");
- Q_ASSERT(aend >= abegin);
-
- int i = std::distance(d.constBegin(), abegin);
- int n = std::distance(abegin, aend);
- remove(i, n);
-
- return d.begin() + i;
-}
-
-template <typename T>
-inline QVector<T> &QVector<T>::fill(parameter_type t, int newSize)
-{
- if (newSize == -1)
- newSize = size();
- if (d->needsDetach() || newSize > capacity()) {
- // must allocate memory
- DataPointer detached(Data::allocate(d->detachCapacity(newSize),
- d->detachFlags()));
- detached->copyAppend(newSize, t);
- d.swap(detached);
- } else {
- // we're detached
- const T copy(t);
- d->assign(d.begin(), d.begin() + qMin(size(), newSize), t);
- if (newSize > size())
- d->copyAppend(newSize - size(), copy);
- }
- return *this;
-}
-
-namespace QtPrivate {
-template <typename T, typename U>
-int indexOf(const QVector<T> &vector, const U &u, int from)
-{
- if (from < 0)
- from = qMax(from + vector.size(), 0);
- if (from < vector.size()) {
- auto n = vector.begin() + from - 1;
- auto e = vector.end();
- while (++n != e)
- if (*n == u)
- return int(n - vector.begin());
- }
- return -1;
-}
-
-template <typename T, typename U>
-int lastIndexOf(const QVector<T> &vector, const U &u, int from)
-{
- if (from < 0)
- from += vector.d->size;
- else if (from >= vector.size())
- from = vector.size() - 1;
- if (from >= 0) {
- auto b = vector.begin();
- auto n = vector.begin() + from + 1;
- while (n != b) {
- if (*--n == u)
- return int(n - b);
- }
- }
- return -1;
-}
-}
-
-template <typename T>
-int QVector<T>::indexOf(const T &t, int from) const noexcept
-{
- return QtPrivate::indexOf<T, T>(*this, t, from);
-}
-
-template <typename T>
-int QVector<T>::lastIndexOf(const T &t, int from) const noexcept
-{
- return QtPrivate::lastIndexOf(*this, t, from);
-}
-
-template <typename T>
-inline QVector<T> QVector<T>::mid(int pos, int len) const
-{
- qsizetype p = pos;
- qsizetype l = len;
- using namespace QtPrivate;
- switch (QContainerImplHelper::mid(d.size, &p, &l)) {
- case QContainerImplHelper::Null:
- case QContainerImplHelper::Empty:
- return QVector();
- case QContainerImplHelper::Full:
- return *this;
- case QContainerImplHelper::Subset:
- break;
- }
-
- // Allocate memory
- DataPointer copied(Data::allocate(l));
- copied->copyAppend(constBegin() + p, constBegin() + p + l);
- return copied;
-}
-
-Q_DECLARE_SEQUENTIAL_ITERATOR(Vector)
-Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(Vector)
-
-template <typename T>
-size_t qHash(const QVector<T> &key, size_t seed = 0)
- noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed)))
-{
- return qHashRange(key.cbegin(), key.cend(), seed);
-}
-
-template <typename T>
-auto operator<(const QVector<T> &lhs, const QVector<T> &rhs)
- noexcept(noexcept(std::lexicographical_compare(lhs.begin(), lhs.end(),
- rhs.begin(), rhs.end())))
- -> decltype(std::declval<T>() < std::declval<T>())
-{
- return std::lexicographical_compare(lhs.begin(), lhs.end(),
- rhs.begin(), rhs.end());
-}
-
-template <typename T>
-auto operator>(const QVector<T> &lhs, const QVector<T> &rhs)
- noexcept(noexcept(lhs < rhs))
- -> decltype(lhs < rhs)
-{
- return rhs < lhs;
-}
-
-template <typename T>
-auto operator<=(const QVector<T> &lhs, const QVector<T> &rhs)
- noexcept(noexcept(lhs < rhs))
- -> decltype(lhs < rhs)
-{
- return !(lhs > rhs);
-}
-
-template <typename T>
-auto operator>=(const QVector<T> &lhs, const QVector<T> &rhs)
- noexcept(noexcept(lhs < rhs))
- -> decltype(lhs < rhs)
-{
- return !(lhs < rhs);
-}
-
-/*
- ### Qt 5:
- ### This needs to be removed for next releases of Qt. It is a workaround for vc++ because
- ### Qt exports QPolygon and QPolygonF that inherit QVector<QPoint> and
- ### QVector<QPointF> respectively.
-*/
-
-#if defined(Q_CC_MSVC) && !defined(QT_BUILD_CORE_LIB)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtCore/qpoint.h>
-QT_END_INCLUDE_NAMESPACE
-extern template class Q_CORE_EXPORT QVector<QPointF>;
-extern template class Q_CORE_EXPORT QVector<QPoint>;
+using QMutableVectorIterator = QMutableListIterator<T>;
+template<typename T>
+using QVectorIterator = QListIterator<T>;
#endif
-QVector<uint> QStringView::toUcs4() const { return QtPrivate::convertToUcs4(*this); }
-
QT_END_NAMESPACE
-#include <QtCore/qbytearraylist.h>
-#include <QtCore/qstringlist.h>
-
#endif // QVECTOR_H
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 27849a2589..f5d034e1e7 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -49,6 +49,7 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qrect.h>
#include <QtCore/qstring.h>
+#include <QtCore/qcontainerfwd.h>
#if defined(Q_OS_DARWIN) || defined(Q_QDOC)
Q_FORWARD_DECLARE_MUTABLE_CG_TYPE(CGImage);
@@ -63,7 +64,6 @@ class QIODevice;
class QStringList;
class QTransform;
class QVariant;
-template <class T> class QVector;
struct QImageData;
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index b4d79462d4..49174e7510 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -44,6 +44,7 @@
#include <QtCore/qatomic.h>
#include <QtCore/qrect.h>
#include <QtGui/qwindowdefs.h>
+#include <QtCore/qcontainerfwd.h>
#ifndef QT_NO_DATASTREAM
#include <QtCore/qdatastream.h>
@@ -52,7 +53,6 @@
QT_BEGIN_NAMESPACE
-template <class T> class QVector;
class QVariant;
struct QRegionPrivate;
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 175a34313c..2b4cf5df6f 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -47,6 +47,7 @@
#include <QtCore/qvariant.h>
#include <QtGui/qfont.h>
#include <QtCore/qurl.h>
+#include <QtCore/qcontainerfwd.h>
Q_MOC_INCLUDE(<QtGui/qtextcursor.h>)
QT_BEGIN_NAMESPACE
@@ -68,7 +69,6 @@ class QRectF;
class QTextOption;
class QTextCursor;
-template<typename T> class QVector;
namespace Qt
{
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index dab69a8b89..4d8112c679 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -347,12 +347,12 @@ struct QScriptItem
int glyph_data_offset;
Q_DECL_CONSTEXPR QFixed height() const noexcept { return ascent + descent; }
private:
- friend class QVector<QScriptItem>;
- QScriptItem() {} // for QVector, don't use
+ friend class QList<QScriptItem>;
+ QScriptItem() {} // for QList, don't use
};
Q_DECLARE_TYPEINFO(QScriptItem, Q_PRIMITIVE_TYPE);
-typedef QVector<QScriptItem> QScriptItemArray;
+typedef QList<QScriptItem> QScriptItemArray;
struct Q_AUTOTEST_EXPORT QScriptLine
{
diff --git a/src/network/access/qhsts_p.h b/src/network/access/qhsts_p.h
index 8ebf7294dd..7253b2835e 100644
--- a/src/network/access/qhsts_p.h
+++ b/src/network/access/qhsts_p.h
@@ -61,13 +61,12 @@
#include <QtCore/qglobal.h>
#include <QtCore/qpair.h>
#include <QtCore/qurl.h>
+#include <QtCore/qcontainerfwd.h>
#include <map>
QT_BEGIN_NAMESPACE
-template <typename T> class QVector;
-
class Q_AUTOTEST_EXPORT QHstsCache
{
public:
diff --git a/src/network/ssl/qdtls.h b/src/network/ssl/qdtls.h
index fe1da23409..93cadc5bc6 100644
--- a/src/network/ssl/qdtls.h
+++ b/src/network/ssl/qdtls.h
@@ -47,6 +47,7 @@
#include <QtCore/qcryptographichash.h>
#include <QtCore/qobject.h>
+#include <QtCore/qcontainerfwd.h>
Q_MOC_INCLUDE(<QtNetwork/QSslPreSharedKeyAuthenticator>)
@@ -109,7 +110,6 @@ private:
};
class QSslPreSharedKeyAuthenticator;
-template<class> class QVector;
class QSslConfiguration;
class QSslCipher;
class QSslError;
diff --git a/src/plugins/generic/tuiotouch/qoscbundle_p.h b/src/plugins/generic/tuiotouch/qoscbundle_p.h
index cb3ec4d251..5aee310017 100644
--- a/src/plugins/generic/tuiotouch/qoscbundle_p.h
+++ b/src/plugins/generic/tuiotouch/qoscbundle_p.h
@@ -43,7 +43,7 @@
#include "qoscmessage_p.h"
-#include <QtCore/QVector>
+#include <QtCore/QList>
QT_BEGIN_NAMESPACE
@@ -51,22 +51,22 @@ class QByteArray;
class QOscBundle
{
- QOscBundle(); // for QVector, don't use
- friend class QVector<QOscBundle>;
+ QOscBundle(); // for QList, don't use
+ friend class QList<QOscBundle>;
public:
explicit QOscBundle(const QByteArray &data);
bool isValid() const { return m_isValid; }
- QVector<QOscBundle> bundles() const { return m_bundles; }
- QVector<QOscMessage> messages() const { return m_messages; }
+ QList<QOscBundle> bundles() const { return m_bundles; }
+ QList<QOscMessage> messages() const { return m_messages; }
private:
bool m_isValid;
bool m_immediate;
quint32 m_timeEpoch;
quint32 m_timePico;
- QVector<QOscBundle> m_bundles;
- QVector<QOscMessage> m_messages;
+ QList<QOscBundle> m_bundles;
+ QList<QOscMessage> m_messages;
};
Q_DECLARE_TYPEINFO(QOscBundle, Q_MOVABLE_TYPE);
diff --git a/src/plugins/generic/tuiotouch/qoscmessage_p.h b/src/plugins/generic/tuiotouch/qoscmessage_p.h
index 76d40ceb18..46c6ca3918 100644
--- a/src/plugins/generic/tuiotouch/qoscmessage_p.h
+++ b/src/plugins/generic/tuiotouch/qoscmessage_p.h
@@ -43,7 +43,6 @@
#include <QtCore/QByteArray>
#include <QtCore/QVariant>
-#include <QtCore/QVector>
#include <QtCore/QList>
@@ -51,8 +50,8 @@ QT_BEGIN_NAMESPACE
class QOscMessage
{
- QOscMessage(); // for QVector, don't use
- friend class QVector<QOscMessage>;
+ QOscMessage(); // for QList, don't use
+ friend class QList<QOscMessage>;
public:
explicit QOscMessage(const QByteArray &data);
diff --git a/src/sql/kernel/qsqlcachedresult_p.h b/src/sql/kernel/qsqlcachedresult_p.h
index 1bca1fd090..0b9dfd3e9a 100644
--- a/src/sql/kernel/qsqlcachedresult_p.h
+++ b/src/sql/kernel/qsqlcachedresult_p.h
@@ -54,11 +54,11 @@
#include <QtSql/private/qtsqlglobal_p.h>
#include "QtSql/qsqlresult.h"
#include "QtSql/private/qsqlresult_p.h"
+#include <QtCore/qcontainerfwd.h>
QT_BEGIN_NAMESPACE
class QVariant;
-template <typename T> class QVector;
class QSqlCachedResultPrivate;
diff --git a/src/sql/kernel/qsqlresult.h b/src/sql/kernel/qsqlresult.h
index 43d53d4027..a7fdae834a 100644
--- a/src/sql/kernel/qsqlresult.h
+++ b/src/sql/kernel/qsqlresult.h
@@ -42,6 +42,7 @@
#include <QtSql/qtsqlglobal.h>
#include <QtCore/qvariant.h>
+#include <QtCore/qcontainerfwd.h>
// for testing:
class tst_QSqlQuery;
@@ -51,7 +52,7 @@ QT_BEGIN_NAMESPACE
class QString;
class QSqlRecord;
-template <typename T> class QVector;
+class QVariant;
class QSqlDriver;
class QSqlError;
class QSqlResultPrivate;
diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h
index 2999bae646..9d221cb34e 100644
--- a/src/widgets/kernel/qlayoutengine_p.h
+++ b/src/widgets/kernel/qlayoutengine_p.h
@@ -54,11 +54,10 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "QtWidgets/qlayoutitem.h"
#include "QtWidgets/qstyle.h"
+#include <QtCore/qcontainerfwd.h>
QT_BEGIN_NAMESPACE
-template <typename T> class QVector;
-
struct QLayoutStruct
{
inline void init(int stretchFactor = 0, int minSize = 0) {
diff --git a/sync.profile b/sync.profile
index 4eb9b0433e..c9359dde57 100644
--- a/sync.profile
+++ b/sync.profile
@@ -40,7 +40,7 @@
"qconfig.h" => "QtConfig",
"qplugin.h" => "QtPlugin",
"qalgorithms.h" => "QtAlgorithms",
- "qlist.h" => "QList",
+ "qvector.h" => "QVector",
"qcontainerfwd.h" => "QtContainerFwd",
"qdebug.h" => "QtDebug",
"qevent.h" => "QtEvents",
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
index 0091636172..a8f6914115 100644
--- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp
@@ -1320,13 +1320,13 @@ void tst_QMetaObject::normalizedSignature_data()
QTest::newRow("function ptr spaces") << "void foo( void ( * ) ( void ))" << "void foo(void(*)())";
QTest::newRow("function ptr void*") << "void foo(void(*)(void*))" << "void foo(void(*)(void*))";
QTest::newRow("function ptr void* spaces") << "void foo( void ( * ) ( void * ))" << "void foo(void(*)(void*))";
- QTest::newRow("template args") << " void foo( QMap<a, a>, QVector<b>) "
- << "void foo(QMap<a,a>,QVector<b>)";
+ QTest::newRow("template args") << " void foo( QMap<a, a>, QList<b>) "
+ << "void foo(QMap<a,a>,QList<b>)";
QTest::newRow("void template args") << " void foo( Foo<void>, Bar<void> ) "
<< "void foo(Foo<void>,Bar<void>)";
QTest::newRow("void* template args") << " void foo( Foo<void*>, Bar<void *> ) "
<< "void foo(Foo<void*>,Bar<void*>)";
- QTest::newRow("rettype") << "QVector<int, int> foo()" << "QVector<int,int>foo()";
+ QTest::newRow("rettype") << "QList<int, int> foo()" << "QList<int,int>foo()";
QTest::newRow("rettype void template") << "Foo<void> foo()" << "Foo<void>foo()";
QTest::newRow("const rettype") << "const QString *foo()" << "const QString*foo()";
QTest::newRow("const ref") << "const QString &foo()" << "const QString&foo()";
@@ -1337,18 +1337,18 @@ void tst_QMetaObject::normalizedSignature_data()
QTest::newRow("const4") << "void foo(const int)" << "void foo(int)";
QTest::newRow("const5") << "void foo(const int, int const, const int &, int const &)"
<< "void foo(int,int,int,int)";
- QTest::newRow("const6") << "void foo(QVector<const int>)" << "void foo(QVector<const int>)";
- QTest::newRow("const7") << "void foo(QVector<const int*>)" << "void foo(QVector<const int*>)";
- QTest::newRow("const8") << "void foo(QVector<int const*>)" << "void foo(QVector<const int*>)";
+ QTest::newRow("const6") << "void foo(QList<const int>)" << "void foo(QList<const int>)";
+ QTest::newRow("const7") << "void foo(QList<const int*>)" << "void foo(QList<const int*>)";
+ QTest::newRow("const8") << "void foo(QList<int const*>)" << "void foo(QList<const int*>)";
QTest::newRow("const9") << "void foo(const Foo<Bar>)" << "void foo(Foo<Bar>)";
QTest::newRow("const10") << "void foo(Foo<Bar>const)" << "void foo(Foo<Bar>)";
QTest::newRow("const11") << "void foo(Foo<Bar> *const)" << "void foo(Foo<Bar>*)";
QTest::newRow("const12") << "void foo(Foo<Bar>const*const *const)" << "void foo(const Foo<Bar>*const*)";
QTest::newRow("const13") << "void foo(const Foo<Bar>&)" << "void foo(Foo<Bar>)";
QTest::newRow("const14") << "void foo(Foo<Bar>const&)" << "void foo(Foo<Bar>)";
- QTest::newRow("QList") << "void foo(QList<int>)" << "void foo(QVector<int>)";
- QTest::newRow("QList1") << "void foo(const Template<QList, MyQList const>)"
- << "void foo(Template<QVector,const MyQList>)";
+ QTest::newRow("QVector") << "void foo(QVector<int>)" << "void foo(QList<int>)";
+ QTest::newRow("QVector1") << "void foo(const Template<QVector, MyQList const>)"
+ << "void foo(Template<QList,const MyQList>)";
QTest::newRow("refref") << "const char* foo(const X &&,X const &&, const X* &&) && "
<< "const char*foo(const X&&,const X&&,const X*&&)&&";
@@ -1373,13 +1373,13 @@ void tst_QMetaObject::normalizedType_data()
QTest::newRow("white") << " int " << "int";
QTest::newRow("const1") << "int const *" << "const int*";
QTest::newRow("const2") << "const int *" << "const int*";
- QTest::newRow("template1") << "QVector<int const *>" << "QVector<const int*>";
- QTest::newRow("template2") << "QVector<const int *>" << "QVector<const int*>";
+ QTest::newRow("template1") << "QList<int const *>" << "QList<const int*>";
+ QTest::newRow("template2") << "QList<const int *>" << "QList<const int*>";
QTest::newRow("template3") << "QMap<QString, int>" << "QMap<QString,int>";
QTest::newRow("template4") << "const QMap<QString, int> &" << "QMap<QString,int>";
- QTest::newRow("template5") << "QVector< ::Foo::Bar>" << "QVector<::Foo::Bar>";
- QTest::newRow("template6") << "QVector<::Foo::Bar>" << "QVector<::Foo::Bar>";
- QTest::newRow("template7") << "QVector<QVector<int> >" << "QVector<QVector<int>>";
+ QTest::newRow("template5") << "QList< ::Foo::Bar>" << "QList<::Foo::Bar>";
+ QTest::newRow("template6") << "QList<::Foo::Bar>" << "QList<::Foo::Bar>";
+ QTest::newRow("template7") << "QList<QList<int> >" << "QList<QList<int>>";
QTest::newRow("template8") << "QMap<const int, const short*>" << "QMap<const int,const short*>";
QTest::newRow("template9") << "QPair<const QPair<int, int const *> , QPair<QHash<int, const char*> > >"
#ifdef _LIBCPP_VERSION
@@ -1387,7 +1387,7 @@ void tst_QMetaObject::normalizedType_data()
#else
<< "std::pair<const std::pair<int,const int*>,std::pair<QHash<int,const char*>>>";
#endif
- QTest::newRow("template10") << "QList<int const * const> const" << "QVector<const int*const>";
+ QTest::newRow("template10") << "QVector<int const * const> const" << "QList<const int*const>";
QTest::newRow("template11") << " QSharedPointer<QVarLengthArray< QString const, ( 16>> 2 )> > const & "
<< "QSharedPointer<QVarLengthArray<const QString,(16>>2)>>";
QTest::newRow("template_sub") << "X<( Y < 8), (Y >6)> const & " << "X<(Y<8),(Y>6)>";
@@ -1402,7 +1402,8 @@ void tst_QMetaObject::normalizedType_data()
QTest::newRow("struct2") << "struct foo const*" << "const foo*";
QTest::newRow("enum") << "enum foo" << "foo";
QTest::newRow("void") << "void" << "void";
- QTest::newRow("QList") << "QList<int>" << "QVector<int>";
+ QTest::newRow("QList") << "QList<int>" << "QList<int>";
+ QTest::newRow("QVector") << "QVector<int>" << "QList<int>";
QTest::newRow("refref") << "X const*const&&" << "const X*const&&";
QTest::newRow("refref2") << "const X<T const&&>&&" << "const X<const T&&>&&";
QTest::newRow("long1") << "long unsigned int long" << "unsigned long long";
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index 651efa53cf..48b46dd98f 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -583,11 +583,11 @@ void tst_QMetaType::typeName_data()
// automatic registration
QTest::newRow("QHash<int,int>") << ::qMetaTypeId<QHash<int, int> >() << QString::fromLatin1("QHash<int,int>");
QTest::newRow("QMap<int,int>") << ::qMetaTypeId<QMap<int, int> >() << QString::fromLatin1("QMap<int,int>");
- QTest::newRow("QVector<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QVector<QMap<int,int>>");
+ QTest::newRow("QVector<QMap<int,int>>") << ::qMetaTypeId<QVector<QMap<int, int> > >() << QString::fromLatin1("QList<QMap<int,int>>");
// automatic registration with automatic QList to QVector aliasing
- QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QVector<int>");
- QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QVector<QVector<int>>");
+ QTest::newRow("QList<int>") << ::qMetaTypeId<QList<int> >() << QString::fromLatin1("QList<int>");
+ QTest::newRow("QVector<QList<int>>") << ::qMetaTypeId<QVector<QList<int> > >() << QString::fromLatin1("QList<QList<int>>");
QTest::newRow("CustomQObject*") << ::qMetaTypeId<CustomQObject*>() << QString::fromLatin1("CustomQObject*");
QTest::newRow("CustomGadget") << ::qMetaTypeId<CustomGadget>() << QString::fromLatin1("CustomGadget");
diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
index 4c8d4bf2e7..ad5a8352a6 100644
--- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp
@@ -240,7 +240,7 @@ public:
*/
class MissedBaseline
{
- friend class QVector<MissedBaseline>;
+ friend class QList<MissedBaseline>;
MissedBaseline() {} // for QVector, don't use
public:
MissedBaseline(const QString &aId,
diff --git a/tests/auto/corelib/tools/CMakeLists.txt b/tests/auto/corelib/tools/CMakeLists.txt
index 89fddb33a2..be0c4932c6 100644
--- a/tests/auto/corelib/tools/CMakeLists.txt
+++ b/tests/auto/corelib/tools/CMakeLists.txt
@@ -16,6 +16,7 @@ add_subdirectory(qfreelist)
add_subdirectory(qhash)
add_subdirectory(qhashfunctions)
add_subdirectory(qline)
+add_subdirectory(qlist)
add_subdirectory(qmakearray)
add_subdirectory(qmap)
add_subdirectory(qmargins)
@@ -38,7 +39,6 @@ add_subdirectory(qsizef)
add_subdirectory(qstl)
add_subdirectory(qtimeline)
add_subdirectory(qvarlengtharray)
-add_subdirectory(qvector)
add_subdirectory(qversionnumber)
if(APPLE)
add_subdirectory(qmacautoreleasepool)
diff --git a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
index 8c90822ec8..558c15d441 100644
--- a/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
+++ b/tests/auto/corelib/tools/containerapisymmetry/tst_containerapisymmetry.cpp
@@ -564,7 +564,7 @@ template<typename ... T>
struct ContainerDuplicatedValuesStrategy<std::vector<T...>> : ContainerAcceptsDuplicateValues {};
template<typename ... T>
-struct ContainerDuplicatedValuesStrategy<QVector<T...>> : ContainerAcceptsDuplicateValues {};
+struct ContainerDuplicatedValuesStrategy<QList<T...>> : ContainerAcceptsDuplicateValues {};
template<typename ... T>
struct ContainerDuplicatedValuesStrategy<QVarLengthArray<T...>> : ContainerAcceptsDuplicateValues {};
diff --git a/tests/auto/corelib/tools/qvector/.gitignore b/tests/auto/corelib/tools/qlist/.gitignore
index 5520039486..5520039486 100644
--- a/tests/auto/corelib/tools/qvector/.gitignore
+++ b/tests/auto/corelib/tools/qlist/.gitignore
diff --git a/tests/auto/corelib/tools/qvector/CMakeLists.txt b/tests/auto/corelib/tools/qlist/CMakeLists.txt
index d180a1be8c..fd771de03a 100644
--- a/tests/auto/corelib/tools/qvector/CMakeLists.txt
+++ b/tests/auto/corelib/tools/qlist/CMakeLists.txt
@@ -4,9 +4,9 @@
## tst_qvector Test:
#####################################################################
-qt_add_test(tst_qvector
+qt_add_test(tst_qlist
SOURCES
- tst_qvector.cpp
+ tst_qlist.cpp
)
## Scopes:
diff --git a/tests/auto/corelib/tools/qvector/qvector.pro b/tests/auto/corelib/tools/qlist/qlist.pro
index 689d9b87a2..17220f377c 100644
--- a/tests/auto/corelib/tools/qvector/qvector.pro
+++ b/tests/auto/corelib/tools/qlist/qlist.pro
@@ -2,6 +2,6 @@ CONFIG += testcase
qtConfig(c++11): CONFIG += c++11
qtConfig(c++14): CONFIG += c++14
qtConfig(c++1z): CONFIG += c++1z
-TARGET = tst_qvector
+TARGET = tst_qlist
QT = core testlib
-SOURCES = $$PWD/tst_qvector.cpp
+SOURCES = $$PWD/tst_qlist.cpp
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
index 899156545d..df3f2023d6 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qlist/tst_qlist.cpp
@@ -30,7 +30,7 @@
#include <QAtomicInt>
#include <QThread>
#include <QSemaphore>
-#include <qvector.h>
+#include <qlist.h>
struct Movable {
Movable(char input = 'j')
@@ -192,7 +192,7 @@ static_assert(QTypeInfo<Custom>::isStatic);
static_assert(QTypeInfo<Custom>::isComplex);
-class tst_QVector : public QObject
+class tst_QList : public QObject
{
Q_OBJECT
private slots:
@@ -373,9 +373,9 @@ template<typename T> struct SimpleValue
return Values[index % MaxIndex];
}
- static QVector<T> vector(int size)
+ static QList<T> vector(int size)
{
- QVector<T> ret;
+ QList<T> ret;
for (int i = 0; i < size; i++)
ret.append(at(i));
return ret;
@@ -400,49 +400,49 @@ const Custom SimpleValue<Custom>::Values[] = { 110, 105, 101, 114, 111, 98 };
#define T_DOG SimpleValue<T>::at(4)
#define T_BLAH SimpleValue<T>::at(5)
-void tst_QVector::constructors_empty() const
+void tst_QList::constructors_empty() const
{
- QVector<int> emptyInt;
- QVector<Movable> emptyMovable;
- QVector<Custom> emptyCustom;
+ QList<int> emptyInt;
+ QList<Movable> emptyMovable;
+ QList<Custom> emptyCustom;
}
-void tst_QVector::constructors_emptyReserveZero() const
+void tst_QList::constructors_emptyReserveZero() const
{
- QVector<int> emptyInt(0);
- QVector<Movable> emptyMovable(0);
- QVector<Custom> emptyCustom(0);
+ QList<int> emptyInt(0);
+ QList<Movable> emptyMovable(0);
+ QList<Custom> emptyCustom(0);
}
-void tst_QVector::constructors_emptyReserve() const
+void tst_QList::constructors_emptyReserve() const
{
// pre-reserve capacity
- QVector<int> myInt(5);
+ QList<int> myInt(5);
QVERIFY(myInt.capacity() == 5);
- QVector<Movable> myMovable(5);
+ QList<Movable> myMovable(5);
QVERIFY(myMovable.capacity() == 5);
- QVector<Custom> myCustom(4);
+ QList<Custom> myCustom(4);
QVERIFY(myCustom.capacity() == 4);
}
-void tst_QVector::constructors_reserveAndInitialize() const
+void tst_QList::constructors_reserveAndInitialize() const
{
// default-initialise items
- QVector<int> myInt(5, 42);
+ QList<int> myInt(5, 42);
QVERIFY(myInt.capacity() == 5);
foreach (int meaningoflife, myInt) {
QCOMPARE(meaningoflife, 42);
}
- QVector<QString> myString(5, QString::fromLatin1("c++"));
+ QList<QString> myString(5, QString::fromLatin1("c++"));
QVERIFY(myString.capacity() == 5);
// make sure all items are initialised ok
foreach (QString meaningoflife, myString) {
QCOMPARE(meaningoflife, QString::fromLatin1("c++"));
}
- QVector<Custom> myCustom(5, Custom('n'));
+ QList<Custom> myCustom(5, Custom('n'));
QVERIFY(myCustom.capacity() == 5);
// make sure all items are initialised ok
foreach (Custom meaningoflife, myCustom) {
@@ -451,38 +451,38 @@ void tst_QVector::constructors_reserveAndInitialize() const
}
template<typename T>
-void tst_QVector::copyConstructor() const
+void tst_QList::copyConstructor() const
{
T value1(SimpleValue<T>::at(0));
T value2(SimpleValue<T>::at(1));
T value3(SimpleValue<T>::at(2));
T value4(SimpleValue<T>::at(3));
{
- QVector<T> v1;
- QVector<T> v2(v1);
+ QList<T> v1;
+ QList<T> v2(v1);
QCOMPARE(v1, v2);
}
{
- QVector<T> v1;
+ QList<T> v1;
v1 << value1 << value2 << value3 << value4;
- QVector<T> v2(v1);
+ QList<T> v2(v1);
QCOMPARE(v1, v2);
}
}
-void tst_QVector::copyConstructorInt() const
+void tst_QList::copyConstructorInt() const
{
copyConstructor<int>();
}
-void tst_QVector::copyConstructorMovable() const
+void tst_QList::copyConstructorMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
copyConstructor<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::copyConstructorCustom() const
+void tst_QList::copyConstructorCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
copyConstructor<Custom>();
@@ -492,11 +492,11 @@ void tst_QVector::copyConstructorCustom() const
template <class T>
static inline void testAssignment()
{
- QVector<T> v1(5);
+ QList<T> v1(5);
QCOMPARE(v1.size(), 5);
QVERIFY(v1.isDetached());
- QVector<T> v2(7);
+ QList<T> v2(7);
QCOMPARE(v2.size(), 7);
QVERIFY(v2.isDetached());
@@ -520,49 +520,49 @@ static inline void testAssignment()
QCOMPARE((void *)v2.constData(), data2);
}
-void tst_QVector::assignmentInt() const
+void tst_QList::assignmentInt() const
{
testAssignment<int>();
}
-void tst_QVector::assignmentMovable() const
+void tst_QList::assignmentMovable() const
{
testAssignment<Movable>();
}
-void tst_QVector::assignmentCustom() const
+void tst_QList::assignmentCustom() const
{
testAssignment<Custom>();
}
template<typename T>
-void tst_QVector::assignFromInitializerList() const
+void tst_QList::assignFromInitializerList() const
{
T val1(SimpleValue<T>::at(1));
T val2(SimpleValue<T>::at(2));
T val3(SimpleValue<T>::at(3));
- QVector<T> v1 = {val1, val2, val3};
- QCOMPARE(v1, QVector<T>() << val1 << val2 << val3);
- QCOMPARE(v1, (QVector<T> {val1, val2, val3}));
+ QList<T> v1 = {val1, val2, val3};
+ QCOMPARE(v1, QList<T>() << val1 << val2 << val3);
+ QCOMPARE(v1, (QList<T> {val1, val2, val3}));
v1 = {};
QCOMPARE(v1.size(), 0);
}
-void tst_QVector::assignFromInitializerListInt() const
+void tst_QList::assignFromInitializerListInt() const
{
assignFromInitializerList<int>();
}
-void tst_QVector::assignFromInitializerListMovable() const
+void tst_QList::assignFromInitializerListMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
assignFromInitializerList<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::assignFromInitializerListCustom() const
+void tst_QList::assignFromInitializerListCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
assignFromInitializerList<Custom>();
@@ -570,19 +570,19 @@ void tst_QVector::assignFromInitializerListCustom() const
}
template<typename T>
-void tst_QVector::add() const
+void tst_QList::add() const
{
{
- QVector<T> empty1;
- QVector<T> empty2;
+ QList<T> empty1;
+ QList<T> empty2;
QVERIFY((empty1 + empty2).isEmpty());
empty1 += empty2;
QVERIFY(empty1.isEmpty());
QVERIFY(empty2.isEmpty());
}
{
- QVector<T> v(12);
- QVector<T> empty;
+ QList<T> v(12);
+ QList<T> empty;
QCOMPARE((v + empty), v);
v += empty;
QVERIFY(!v.isEmpty());
@@ -590,8 +590,8 @@ void tst_QVector::add() const
QVERIFY(empty.isEmpty());
}
{
- QVector<T> v1(12);
- QVector<T> v2;
+ QList<T> v1(12);
+ QList<T> v2;
v2 += v1;
QVERIFY(!v1.isEmpty());
QCOMPARE(v1.size(), 12);
@@ -600,19 +600,19 @@ void tst_QVector::add() const
}
}
-void tst_QVector::addInt() const
+void tst_QList::addInt() const
{
add<int>();
}
-void tst_QVector::addMovable() const
+void tst_QList::addMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
add<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::addCustom() const
+void tst_QList::addCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
add<Custom>();
@@ -620,10 +620,10 @@ void tst_QVector::addCustom() const
}
template<typename T>
-void tst_QVector::append() const
+void tst_QList::append() const
{
{
- QVector<T> myvec;
+ QList<T> myvec;
myvec.append(SimpleValue<T>::at(0));
QVERIFY(myvec.size() == 1);
myvec.append(SimpleValue<T>::at(1));
@@ -631,59 +631,59 @@ void tst_QVector::append() const
myvec.append(SimpleValue<T>::at(2));
QVERIFY(myvec.size() == 3);
- QCOMPARE(myvec, QVector<T>() << SimpleValue<T>::at(0)
+ QCOMPARE(myvec, QList<T>() << SimpleValue<T>::at(0)
<< SimpleValue<T>::at(1)
<< SimpleValue<T>::at(2));
}
{
- QVector<T> v(2);
+ QList<T> v(2);
v.append(SimpleValue<T>::at(0));
QVERIFY(v.size() == 3);
QCOMPARE(v.at(v.size() - 1), SimpleValue<T>::at(0));
}
{
- QVector<T> v(2);
+ QList<T> v(2);
v.reserve(12);
v.append(SimpleValue<T>::at(0));
QVERIFY(v.size() == 3);
QCOMPARE(v.at(v.size() - 1), SimpleValue<T>::at(0));
}
{
- QVector<int> v;
+ QList<int> v;
v << 1 << 2 << 3;
- QVector<int> x;
+ QList<int> x;
x << 4 << 5 << 6;
v.append(x);
- QVector<int> combined;
+ QList<int> combined;
combined << 1 << 2 << 3 << 4 << 5 << 6;
QCOMPARE(v, combined);
}
}
-void tst_QVector::appendInt() const
+void tst_QList::appendInt() const
{
append<int>();
}
-void tst_QVector::appendMovable() const
+void tst_QList::appendMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
append<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::appendCustom() const
+void tst_QList::appendCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
append<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::appendRvalue() const
+void tst_QList::appendRvalue() const
{
- QVector<QString> v;
+ QList<QString> v;
v.append("hello");
QString world = "world";
v.append(std::move(world));
@@ -692,9 +692,9 @@ void tst_QVector::appendRvalue() const
QCOMPARE(v.back(), QString("world"));
}
-void tst_QVector::at() const
+void tst_QList::at() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "foo" << "bar" << "baz";
QVERIFY(myvec.size() == 3);
@@ -719,9 +719,9 @@ void tst_QVector::at() const
}
template<typename T>
-void tst_QVector::capacity() const
+void tst_QList::capacity() const
{
- QVector<T> myvec;
+ QList<T> myvec;
// TODO: is this guaranteed? seems a safe assumption, but I suppose preallocation of a
// few items isn't an entirely unforseeable possibility.
@@ -748,19 +748,19 @@ void tst_QVector::capacity() const
QVERIFY(myvec.capacity() == 0);
}
-void tst_QVector::capacityInt() const
+void tst_QList::capacityInt() const
{
capacity<int>();
}
-void tst_QVector::capacityMovable() const
+void tst_QList::capacityMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
capacity<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::capacityCustom() const
+void tst_QList::capacityCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
capacity<Custom>();
@@ -768,9 +768,9 @@ void tst_QVector::capacityCustom() const
}
template<typename T>
-void tst_QVector::clear() const
+void tst_QList::clear() const
{
- QVector<T> myvec;
+ QList<T> myvec;
myvec << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2);
const auto oldCapacity = myvec.capacity();
@@ -780,37 +780,37 @@ void tst_QVector::clear() const
QCOMPARE(myvec.capacity(), oldCapacity);
}
-void tst_QVector::clearInt() const
+void tst_QList::clearInt() const
{
clear<int>();
}
-void tst_QVector::clearMovable() const
+void tst_QList::clearMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
clear<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::clearCustom() const
+void tst_QList::clearCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
clear<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::constData() const
+void tst_QList::constData() const
{
int arr[] = { 42, 43, 44 };
- QVector<int> myvec;
+ QList<int> myvec;
myvec << 42 << 43 << 44;
QVERIFY(memcmp(myvec.constData(), reinterpret_cast<const int *>(&arr), sizeof(int) * 3) == 0);
}
-void tst_QVector::contains() const
+void tst_QList::contains() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "aaa" << "bbb" << "ccc";
QVERIFY(myvec.contains(QLatin1String("aaa")));
@@ -824,12 +824,12 @@ void tst_QVector::contains() const
}
template<typename T>
-void tst_QVector::count() const
+void tst_QList::count() const
{
// total size
{
// zero size
- QVector<T> myvec;
+ QList<T> myvec;
QVERIFY(myvec.count() == 0);
// grow
@@ -847,7 +847,7 @@ void tst_QVector::count() const
// count of items
{
- QVector<T> myvec;
+ QList<T> myvec;
myvec << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2);
// initial tests
@@ -864,39 +864,39 @@ void tst_QVector::count() const
}
}
-void tst_QVector::countInt() const
+void tst_QList::countInt() const
{
count<int>();
}
-void tst_QVector::countMovable() const
+void tst_QList::countMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
count<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::countCustom() const
+void tst_QList::countCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
count<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::cpp17ctad() const
+void tst_QList::cpp17ctad() const
{
#ifdef __cpp_deduction_guides
#define QVERIFY_IS_VECTOR_OF(obj, Type) \
- QVERIFY2((std::is_same<decltype(obj), QVector<Type>>::value), \
+ QVERIFY2((std::is_same<decltype(obj), QList<Type>>::value), \
QMetaType::typeName(qMetaTypeId<decltype(obj)::value_type>()))
#define CHECK(Type, One, Two, Three) \
do { \
const Type v[] = {One, Two, Three}; \
- QVector v1 = {One, Two, Three}; \
+ QList v1 = {One, Two, Three}; \
QVERIFY_IS_VECTOR_OF(v1, Type); \
- QVector v2(v1.begin(), v1.end()); \
+ QList v2(v1.begin(), v1.end()); \
QVERIFY_IS_VECTOR_OF(v2, Type); \
- QVector v3(std::begin(v), std::end(v)); \
+ QList v3(std::begin(v), std::end(v)); \
QVERIFY_IS_VECTOR_OF(v3, Type); \
} while (false) \
/*end*/
@@ -910,9 +910,9 @@ void tst_QVector::cpp17ctad() const
#endif
}
-void tst_QVector::data() const
+void tst_QList::data() const
{
- QVector<int> myvec;
+ QList<int> myvec;
myvec << 42 << 43 << 44;
// make sure it starts off ok
@@ -929,9 +929,9 @@ void tst_QVector::data() const
}
template<typename T>
-void tst_QVector::empty() const
+void tst_QList::empty() const
{
- QVector<T> myvec;
+ QList<T> myvec;
// starts empty
QVERIFY(myvec.empty());
@@ -945,28 +945,28 @@ void tst_QVector::empty() const
QVERIFY(myvec.empty());
}
-void tst_QVector::emptyInt() const
+void tst_QList::emptyInt() const
{
empty<int>();
}
-void tst_QVector::emptyMovable() const
+void tst_QList::emptyMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
empty<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::emptyCustom() const
+void tst_QList::emptyCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
empty<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::endsWith() const
+void tst_QList::endsWith() const
{
- QVector<int> myvec;
+ QList<int> myvec;
// empty vector
QVERIFY(!myvec.endsWith(1));
@@ -985,26 +985,26 @@ void tst_QVector::endsWith() const
}
template<typename T>
-void tst_QVector::eraseEmpty() const
+void tst_QList::eraseEmpty() const
{
- QVector<T> v;
+ QList<T> v;
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
-void tst_QVector::eraseEmptyInt() const
+void tst_QList::eraseEmptyInt() const
{
eraseEmpty<int>();
}
-void tst_QVector::eraseEmptyMovable() const
+void tst_QList::eraseEmptyMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
eraseEmpty<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::eraseEmptyCustom() const
+void tst_QList::eraseEmptyCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
eraseEmpty<Custom>();
@@ -1012,27 +1012,27 @@ void tst_QVector::eraseEmptyCustom() const
}
template<typename T>
-void tst_QVector::eraseEmptyReserved() const
+void tst_QList::eraseEmptyReserved() const
{
- QVector<T> v;
+ QList<T> v;
v.reserve(10);
v.erase(v.begin(), v.end());
QCOMPARE(v.size(), 0);
}
-void tst_QVector::eraseEmptyReservedInt() const
+void tst_QList::eraseEmptyReservedInt() const
{
eraseEmptyReserved<int>();
}
-void tst_QVector::eraseEmptyReservedMovable() const
+void tst_QList::eraseEmptyReservedMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
eraseEmptyReserved<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::eraseEmptyReservedCustom() const
+void tst_QList::eraseEmptyReservedCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
eraseEmptyReserved<Custom>();
@@ -1042,13 +1042,13 @@ void tst_QVector::eraseEmptyReservedCustom() const
template<typename T>
struct SharedVectorChecker
{
- SharedVectorChecker(const QVector<T> &original, bool doCopyVector)
+ SharedVectorChecker(const QList<T> &original, bool doCopyVector)
: originalSize(-1),
copy(0)
{
if (doCopyVector) {
originalSize = original.size();
- copy = new QVector<T>(original);
+ copy = new QList<T>(original);
// this is unlikely to fail, but if the check in the destructor fails it's good to know that
// we were still alright here.
QCOMPARE(originalSize, copy->size());
@@ -1063,18 +1063,18 @@ struct SharedVectorChecker
}
int originalSize;
- QVector<T> *copy;
+ QList<T> *copy;
};
template<typename T>
-void tst_QVector::erase(bool shared) const
+void tst_QList::erase(bool shared) const
{
// note: remove() is actually more efficient, and more dangerous, because it uses the non-detaching
// begin() / end() internally. you can also use constBegin() and constEnd() with erase(), but only
// using reinterpret_cast... because both iterator types are really just pointers.
// so we use a mix of erase() and remove() to cover more cases.
{
- QVector<T> v = SimpleValue<T>::vector(12);
+ QList<T> v = SimpleValue<T>::vector(12);
SharedVectorChecker<T> svc(v, shared);
v.erase(v.begin());
QCOMPARE(v.size(), 11);
@@ -1086,7 +1086,7 @@ void tst_QVector::erase(bool shared) const
QCOMPARE(SimpleValue<T>::vector(12), *svc.copy);
}
{
- QVector<T> v = SimpleValue<T>::vector(12);
+ QList<T> v = SimpleValue<T>::vector(12);
SharedVectorChecker<T> svc(v, shared);
v.remove(1);
QCOMPARE(v.size(), 11);
@@ -1100,7 +1100,7 @@ void tst_QVector::erase(bool shared) const
QCOMPARE(SimpleValue<T>::vector(12), *svc.copy);
}
{
- QVector<T> v = SimpleValue<T>::vector(12);
+ QList<T> v = SimpleValue<T>::vector(12);
SharedVectorChecker<T> svc(v, shared);
v.erase(v.begin(), v.end() - 1);
QCOMPARE(v.size(), 1);
@@ -1109,7 +1109,7 @@ void tst_QVector::erase(bool shared) const
QCOMPARE(SimpleValue<T>::vector(12), *svc.copy);
}
{
- QVector<T> v = SimpleValue<T>::vector(12);
+ QList<T> v = SimpleValue<T>::vector(12);
SharedVectorChecker<T> svc(v, shared);
v.remove(5);
QCOMPARE(v.size(), 11);
@@ -1126,48 +1126,48 @@ void tst_QVector::erase(bool shared) const
}
}
-void tst_QVector::eraseInt() const
+void tst_QList::eraseInt() const
{
erase<int>(false);
}
-void tst_QVector::eraseIntShared() const
+void tst_QList::eraseIntShared() const
{
erase<int>(true);
}
-void tst_QVector::eraseMovable() const
+void tst_QList::eraseMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
erase<Movable>(false);
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::eraseMovableShared() const
+void tst_QList::eraseMovableShared() const
{
const int instancesCount = Movable::counter.loadAcquire();
erase<Movable>(true);
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::eraseCustom() const
+void tst_QList::eraseCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
erase<Custom>(false);
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::eraseCustomShared() const
+void tst_QList::eraseCustomShared() const
{
const int instancesCount = Custom::counter.loadAcquire();
erase<Custom>(true);
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-template<typename T> void tst_QVector::eraseReserved() const
+template<typename T> void tst_QList::eraseReserved() const
{
{
- QVector<T> v(12);
+ QList<T> v(12);
v.reserve(16);
v.erase(v.begin());
QCOMPARE(v.size(), 11);
@@ -1175,7 +1175,7 @@ template<typename T> void tst_QVector::eraseReserved() const
QCOMPARE(v.size(), 0);
}
{
- QVector<T> v(12);
+ QList<T> v(12);
v.reserve(16);
v.erase(v.begin() + 1);
QCOMPARE(v.size(), 11);
@@ -1183,13 +1183,13 @@ template<typename T> void tst_QVector::eraseReserved() const
QCOMPARE(v.size(), 1);
}
{
- QVector<T> v(12);
+ QList<T> v(12);
v.reserve(16);
v.erase(v.begin(), v.end() - 1);
QCOMPARE(v.size(), 1);
}
{
- QVector<T> v(12);
+ QList<T> v(12);
v.reserve(16);
v.erase(v.begin() + 5);
QCOMPARE(v.size(), 11);
@@ -1198,19 +1198,19 @@ template<typename T> void tst_QVector::eraseReserved() const
}
}
-void tst_QVector::eraseReservedInt() const
+void tst_QList::eraseReservedInt() const
{
eraseReserved<int>();
}
-void tst_QVector::eraseReservedMovable() const
+void tst_QList::eraseReservedMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
eraseReserved<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::eraseReservedCustom() const
+void tst_QList::eraseReservedCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
eraseReserved<Custom>();
@@ -1218,58 +1218,58 @@ void tst_QVector::eraseReservedCustom() const
}
template<typename T>
-void tst_QVector::fill() const
+void tst_QList::fill() const
{
- QVector<T> myvec;
+ QList<T> myvec;
// resize
myvec.resize(5);
myvec.fill(SimpleValue<T>::at(1));
- QCOMPARE(myvec, QVector<T>() << SimpleValue<T>::at(1) << SimpleValue<T>::at(1)
+ QCOMPARE(myvec, QList<T>() << SimpleValue<T>::at(1) << SimpleValue<T>::at(1)
<< SimpleValue<T>::at(1) << SimpleValue<T>::at(1)
<< SimpleValue<T>::at(1));
// make sure it can resize itself too
myvec.fill(SimpleValue<T>::at(2), 10);
- QCOMPARE(myvec, QVector<T>() << SimpleValue<T>::at(2) << SimpleValue<T>::at(2)
+ QCOMPARE(myvec, QList<T>() << SimpleValue<T>::at(2) << SimpleValue<T>::at(2)
<< SimpleValue<T>::at(2) << SimpleValue<T>::at(2)
<< SimpleValue<T>::at(2) << SimpleValue<T>::at(2)
<< SimpleValue<T>::at(2) << SimpleValue<T>::at(2)
<< SimpleValue<T>::at(2) << SimpleValue<T>::at(2));
}
-void tst_QVector::fillInt() const
+void tst_QList::fillInt() const
{
fill<int>();
}
-void tst_QVector::fillMovable() const
+void tst_QList::fillMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
fill<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::fillCustom() const
+void tst_QList::fillCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
fill<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::fillDetaches() const
+void tst_QList::fillDetaches() const
{
- QVector<int> test = { 1, 2, 3 };
- QVector<int> copy = test;
+ QList<int> test = { 1, 2, 3 };
+ QList<int> copy = test;
copy.fill(42);
- QCOMPARE(test, QVector<int>({1, 2, 3}));
- QCOMPARE(copy, QVector<int>({42, 42, 42}));
+ QCOMPARE(test, QList<int>({1, 2, 3}));
+ QCOMPARE(copy, QList<int>({42, 42, 42}));
}
-void tst_QVector::first() const
+void tst_QList::first() const
{
- QVector<int> myvec;
+ QList<int> myvec;
myvec << 69 << 42 << 3;
// test it starts ok
@@ -1287,16 +1287,16 @@ void tst_QVector::first() const
QCOMPARE(myvec.constFirst(), 23);
}
-void tst_QVector::constFirst() const
+void tst_QList::constFirst() const
{
- QVector<int> myvec;
+ QList<int> myvec;
myvec << 69 << 42 << 3;
// test it starts ok
QCOMPARE(myvec.constFirst(), 69);
QVERIFY(myvec.isDetached());
- QVector<int> myvecCopy = myvec;
+ QList<int> myvecCopy = myvec;
QVERIFY(!myvec.isDetached());
QVERIFY(!myvecCopy.isDetached());
QVERIFY(myvec.isSharedWith(myvecCopy));
@@ -1355,32 +1355,32 @@ void tst_QVector::constFirst() const
template<typename T>
-void tst_QVector::fromList() const
+void tst_QList::fromList() const
{
QList<T> list;
list << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2) << SimpleValue<T>::at(3);
- QVector<T> myvec;
- myvec = QVector<T>::fromList(list);
+ QList<T> myvec;
+ myvec = QList<T>::fromList(list);
// test it worked ok
- QCOMPARE(myvec, QVector<T>() << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2) << SimpleValue<T>::at(3));
+ QCOMPARE(myvec, QList<T>() << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2) << SimpleValue<T>::at(3));
QCOMPARE(list, QList<T>() << SimpleValue<T>::at(0) << SimpleValue<T>::at(1) << SimpleValue<T>::at(2) << SimpleValue<T>::at(3));
}
-void tst_QVector::fromListInt() const
+void tst_QList::fromListInt() const
{
fromList<int>();
}
-void tst_QVector::fromListMovable() const
+void tst_QList::fromListMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
fromList<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::fromListCustom() const
+void tst_QList::fromListCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
fromList<Custom>();
@@ -1388,7 +1388,7 @@ void tst_QVector::fromListCustom() const
}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
-void tst_QVector::fromStdVector() const
+void tst_QList::fromStdVector() const
{
// stl = :(
std::vector<QString> svec;
@@ -1396,16 +1396,16 @@ void tst_QVector::fromStdVector() const
svec.push_back(QLatin1String("bbb"));
svec.push_back(QLatin1String("ninjas"));
svec.push_back(QLatin1String("pirates"));
- QVector<QString> myvec = QVector<QString>::fromStdVector(svec);
+ QList<QString> myvec = QList<QString>::fromStdVector(svec);
// test it converts ok
- QCOMPARE(myvec, QVector<QString>() << "aaa" << "bbb" << "ninjas" << "pirates");
+ QCOMPARE(myvec, QList<QString>() << "aaa" << "bbb" << "ninjas" << "pirates");
}
#endif
-void tst_QVector::indexOf() const
+void tst_QList::indexOf() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C" << "B" << "A";
QVERIFY(myvec.indexOf("B") == 1);
@@ -1428,9 +1428,9 @@ void tst_QVector::indexOf() const
}
template <typename T>
-void tst_QVector::insert() const
+void tst_QList::insert() const
{
- QVector<T> myvec;
+ QList<T> myvec;
const T
tA = SimpleValue<T>::at(0),
tB = SimpleValue<T>::at(1),
@@ -1440,7 +1440,7 @@ void tst_QVector::insert() const
tT = SimpleValue<T>::at(5),
ti = SimpleValue<T>::at(6);
myvec << tA << tB << tC;
- QVector<T> myvec2 = myvec;
+ QList<T> myvec2 = myvec;
// first position
QCOMPARE(myvec.at(0), tA);
@@ -1475,7 +1475,7 @@ void tst_QVector::insert() const
// insert a lot of garbage in the middle
myvec.insert(2, 2, ti);
- QCOMPARE(myvec, QVector<T>() << tX << tZ << ti << ti
+ QCOMPARE(myvec, QList<T>() << tX << tZ << ti << ti
<< tA << tB << tC << tT);
myvec2.insert(myvec2.begin() + 2, 2, ti);
@@ -1484,35 +1484,35 @@ void tst_QVector::insert() const
// insert from references to the same container:
myvec.insert(0, 1, myvec[5]); // inserts tB
myvec2.insert(0, 1, myvec2[5]); // inserts tB
- QCOMPARE(myvec, QVector<T>() << tB << tX << tZ << ti << ti
+ QCOMPARE(myvec, QList<T>() << tB << tX << tZ << ti << ti
<< tA << tB << tC << tT);
QCOMPARE(myvec2, myvec);
- myvec.insert(0, 1, const_cast<const QVector<T>&>(myvec)[0]); // inserts tB
- myvec2.insert(0, 1, const_cast<const QVector<T>&>(myvec2)[0]); // inserts tB
- QCOMPARE(myvec, QVector<T>() << tB << tB << tX << tZ << ti << ti
+ myvec.insert(0, 1, const_cast<const QList<T>&>(myvec)[0]); // inserts tB
+ myvec2.insert(0, 1, const_cast<const QList<T>&>(myvec2)[0]); // inserts tB
+ QCOMPARE(myvec, QList<T>() << tB << tB << tX << tZ << ti << ti
<< tA << tB << tC << tT);
QCOMPARE(myvec2, myvec);
}
-void tst_QVector::insertInt() const
+void tst_QList::insertInt() const
{
insert<int>();
}
-void tst_QVector::insertMovable() const
+void tst_QList::insertMovable() const
{
insert<Movable>();
}
-void tst_QVector::insertCustom() const
+void tst_QList::insertCustom() const
{
insert<Custom>();
}
-void tst_QVector::isEmpty() const
+void tst_QList::isEmpty() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
// starts ok
QVERIFY(myvec.isEmpty());
@@ -1526,9 +1526,9 @@ void tst_QVector::isEmpty() const
QVERIFY(myvec.isEmpty());
}
-void tst_QVector::last() const
+void tst_QList::last() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C";
// test starts ok
@@ -1546,16 +1546,16 @@ void tst_QVector::last() const
QCOMPARE(myvec.constLast(), QLatin1String("C"));
}
-void tst_QVector::constLast() const
+void tst_QList::constLast() const
{
- QVector<int> myvec;
+ QList<int> myvec;
myvec << 69 << 42 << 3;
// test it starts ok
QCOMPARE(myvec.constLast(), 3);
QVERIFY(myvec.isDetached());
- QVector<int> myvecCopy = myvec;
+ QList<int> myvecCopy = myvec;
QVERIFY(!myvec.isDetached());
QVERIFY(!myvecCopy.isDetached());
QVERIFY(myvec.isSharedWith(myvecCopy));
@@ -1612,9 +1612,9 @@ void tst_QVector::constLast() const
QVERIFY(myvecCopy.isSharedWith(myvec));
}
-void tst_QVector::lastIndexOf() const
+void tst_QList::lastIndexOf() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C" << "B" << "A";
QVERIFY(myvec.lastIndexOf("B") == 3);
@@ -1635,21 +1635,21 @@ void tst_QVector::lastIndexOf() const
QVERIFY(myvec.lastIndexOf("A", 2) == -1);
}
-void tst_QVector::mid() const
+void tst_QList::mid() const
{
- QVector<QString> list;
+ QList<QString> list;
list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty";
- QCOMPARE(list.mid(3, 3), QVector<QString>() << "bak" << "buck" << "hello");
- QCOMPARE(list.mid(6, 10), QVector<QString>() << "kitty");
+ QCOMPARE(list.mid(3, 3), QList<QString>() << "bak" << "buck" << "hello");
+ QCOMPARE(list.mid(6, 10), QList<QString>() << "kitty");
QCOMPARE(list.mid(-1, 20), list);
- QCOMPARE(list.mid(4), QVector<QString>() << "buck" << "hello" << "kitty");
+ QCOMPARE(list.mid(4), QList<QString>() << "buck" << "hello" << "kitty");
}
template <typename T>
-void tst_QVector::qhash() const
+void tst_QList::qhash() const
{
- QVector<T> l1, l2;
+ QList<T> l1, l2;
QCOMPARE(qHash(l1), qHash(l2));
l1 << SimpleValue<T>::at(0);
l2 << SimpleValue<T>::at(0);
@@ -1657,37 +1657,37 @@ void tst_QVector::qhash() const
}
template <typename T>
-void tst_QVector::move() const
+void tst_QList::move() const
{
- QVector<T> list;
+ QList<T> list;
list << T_FOO << T_BAR << T_BAZ;
// move an item
list.move(0, list.count() - 1);
- QCOMPARE(list, QVector<T>() << T_BAR << T_BAZ << T_FOO);
+ QCOMPARE(list, QList<T>() << T_BAR << T_BAZ << T_FOO);
// move it back
list.move(list.count() - 1, 0);
- QCOMPARE(list, QVector<T>() << T_FOO << T_BAR << T_BAZ);
+ QCOMPARE(list, QList<T>() << T_FOO << T_BAR << T_BAZ);
// move an item in the middle
list.move(1, 0);
- QCOMPARE(list, QVector<T>() << T_BAR << T_FOO << T_BAZ);
+ QCOMPARE(list, QList<T>() << T_BAR << T_FOO << T_BAZ);
}
-void tst_QVector::moveInt() const
+void tst_QList::moveInt() const
{
move<int>();
}
-void tst_QVector::moveMovable() const
+void tst_QList::moveMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
move<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::moveCustom() const
+void tst_QList::moveCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
move<Custom>();
@@ -1695,9 +1695,9 @@ void tst_QVector::moveCustom() const
}
template<typename T>
-void tst_QVector::prepend() const
+void tst_QList::prepend() const
{
- QVector<T> myvec;
+ QList<T> myvec;
T val1 = SimpleValue<T>::at(0);
T val2 = SimpleValue<T>::at(1);
T val3 = SimpleValue<T>::at(2);
@@ -1730,36 +1730,36 @@ void tst_QVector::prepend() const
QCOMPARE(myvec.at(0), val5);
}
-void tst_QVector::prependInt() const
+void tst_QList::prependInt() const
{
prepend<int>();
}
-void tst_QVector::prependMovable() const
+void tst_QList::prependMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
prepend<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::prependCustom() const
+void tst_QList::prependCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
prepend<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::removeAllWithAlias() const
+void tst_QList::removeAllWithAlias() const
{
- QVector<QString> strings;
+ QList<QString> strings;
strings << "One" << "Two" << "Three" << "One" /* must be distinct, but equal */;
QCOMPARE(strings.removeAll(strings.front()), 2); // will trigger asan/ubsan
}
template<typename T>
-void tst_QVector::remove() const
+void tst_QList::remove() const
{
- QVector<T> myvec;
+ QList<T> myvec;
T val1 = SimpleValue<T>::at(1);
T val2 = SimpleValue<T>::at(2);
T val3 = SimpleValue<T>::at(3);
@@ -1769,45 +1769,45 @@ void tst_QVector::remove() const
myvec << val1 << val2 << val3;
// remove middle
myvec.remove(1);
- QCOMPARE(myvec, QVector<T>() << val1 << val3 << val1 << val2 << val3 << val1 << val2 << val3);
+ QCOMPARE(myvec, QList<T>() << val1 << val3 << val1 << val2 << val3 << val1 << val2 << val3);
// removeOne()
QVERIFY(!myvec.removeOne(val4));
QVERIFY(myvec.removeOne(val2));
- QCOMPARE(myvec, QVector<T>() << val1 << val3 << val1 << val3 << val1 << val2 << val3);
+ QCOMPARE(myvec, QList<T>() << val1 << val3 << val1 << val3 << val1 << val2 << val3);
- QVector<T> myvecCopy = myvec;
+ QList<T> myvecCopy = myvec;
QVERIFY(myvecCopy.isSharedWith(myvec));
// removeAll()
QCOMPARE(myvec.removeAll(val4), 0);
QVERIFY(myvecCopy.isSharedWith(myvec));
QCOMPARE(myvec.removeAll(val1), 3);
QVERIFY(!myvecCopy.isSharedWith(myvec));
- QCOMPARE(myvec, QVector<T>() << val3 << val3 << val2 << val3);
+ QCOMPARE(myvec, QList<T>() << val3 << val3 << val2 << val3);
myvecCopy = myvec;
QVERIFY(myvecCopy.isSharedWith(myvec));
QCOMPARE(myvec.removeAll(val2), 1);
QVERIFY(!myvecCopy.isSharedWith(myvec));
- QCOMPARE(myvec, QVector<T>() << val3 << val3 << val3);
+ QCOMPARE(myvec, QList<T>() << val3 << val3 << val3);
// remove rest
myvec.remove(0, 3);
- QCOMPARE(myvec, QVector<T>());
+ QCOMPARE(myvec, QList<T>());
}
-void tst_QVector::removeInt() const
+void tst_QList::removeInt() const
{
remove<int>();
}
-void tst_QVector::removeMovable() const
+void tst_QList::removeMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
remove<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::removeCustom() const
+void tst_QList::removeCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
remove<Custom>();
@@ -1827,10 +1827,10 @@ struct RemoveLastTestClass
}
};
-void tst_QVector::removeFirstLast() const
+void tst_QList::removeFirstLast() const
{
// pop_pack - pop_front
- QVector<int> t, t2;
+ QList<int> t, t2;
t.append(1);
t.append(2);
t.append(3);
@@ -1857,7 +1857,7 @@ void tst_QVector::removeFirstLast() const
QCOMPARE(t2.at(1), 3);
// remove first
- QVector<int> x, y;
+ QList<int> x, y;
x.append(1);
x.append(2);
y = x;
@@ -1867,7 +1867,7 @@ void tst_QVector::removeFirstLast() const
QCOMPARE(x.at(0), 2);
// remove Last
- QVector<RemoveLastTestClass> v;
+ QList<RemoveLastTestClass> v;
v.resize(2);
v[0].other = &(v[1]);
v[1].other = &(v[0]);
@@ -1878,7 +1878,7 @@ void tst_QVector::removeFirstLast() const
QCOMPARE(v.at(0).deleted, false);
// check iterator
int count = 0;
- for (QVector<RemoveLastTestClass>::const_iterator i = v.constBegin(); i != v.constEnd(); ++i) {
+ for (QList<RemoveLastTestClass>::const_iterator i = v.constBegin(); i != v.constEnd(); ++i) {
++count;
QVERIFY(i->other == 0);
QCOMPARE(i->deleted, false);
@@ -1889,7 +1889,7 @@ void tst_QVector::removeFirstLast() const
v.removeLast();
QCOMPARE(v.size(), 0);
// Check if we do correct realloc
- QVector<int> v2, v3;
+ QList<int> v2, v3;
v2.append(1);
v2.append(2);
v3 = v2; // shared
@@ -1901,7 +1901,7 @@ void tst_QVector::removeFirstLast() const
QCOMPARE(v3.at(1), 2);
// Remove last with shared
- QVector<int> z1, z2;
+ QList<int> z1, z2;
z1.append(9);
z2 = z1;
z1.removeLast();
@@ -1911,19 +1911,19 @@ void tst_QVector::removeFirstLast() const
}
-void tst_QVector::resizePOD_data() const
+void tst_QList::resizePOD_data() const
{
- QTest::addColumn<QVector<int> >("vector");
+ QTest::addColumn<QList<int> >("vector");
QTest::addColumn<int>("size");
QVERIFY(!QTypeInfo<int>::isComplex);
QVERIFY(!QTypeInfo<int>::isStatic);
- QVector<int> null;
- QVector<int> empty(0, 5);
- QVector<int> emptyReserved;
- QVector<int> nonEmpty;
- QVector<int> nonEmptyReserved;
+ QList<int> null;
+ QList<int> empty(0, 5);
+ QList<int> emptyReserved;
+ QList<int> nonEmpty;
+ QList<int> nonEmptyReserved;
emptyReserved.reserve(10);
nonEmptyReserved.reserve(15);
@@ -1939,9 +1939,9 @@ void tst_QVector::resizePOD_data() const
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
}
-void tst_QVector::resizePOD() const
+void tst_QList::resizePOD() const
{
- QFETCH(QVector<int>, vector);
+ QFETCH(QList<int>, vector);
QFETCH(int, size);
const int oldSize = vector.size();
@@ -1959,19 +1959,19 @@ void tst_QVector::resizePOD() const
QVERIFY(vector.capacity() <= capacity);
}
-void tst_QVector::resizeComplexMovable_data() const
+void tst_QList::resizeComplexMovable_data() const
{
- QTest::addColumn<QVector<Movable> >("vector");
+ QTest::addColumn<QList<Movable> >("vector");
QTest::addColumn<int>("size");
QVERIFY(QTypeInfo<Movable>::isComplex);
QVERIFY(!QTypeInfo<Movable>::isStatic);
- QVector<Movable> null;
- QVector<Movable> empty(0, 'Q');
- QVector<Movable> emptyReserved;
- QVector<Movable> nonEmpty;
- QVector<Movable> nonEmptyReserved;
+ QList<Movable> null;
+ QList<Movable> empty(0, 'Q');
+ QList<Movable> emptyReserved;
+ QList<Movable> nonEmpty;
+ QList<Movable> nonEmptyReserved;
emptyReserved.reserve(10);
nonEmptyReserved.reserve(15);
@@ -1987,11 +1987,11 @@ void tst_QVector::resizeComplexMovable_data() const
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
}
-void tst_QVector::resizeComplexMovable() const
+void tst_QList::resizeComplexMovable() const
{
const int items = Movable::counter.loadAcquire();
{
- QFETCH(QVector<Movable>, vector);
+ QFETCH(QList<Movable>, vector);
QFETCH(int, size);
const int oldSize = vector.size();
@@ -2011,19 +2011,19 @@ void tst_QVector::resizeComplexMovable() const
QCOMPARE(items, Movable::counter.loadAcquire());
}
-void tst_QVector::resizeComplex_data() const
+void tst_QList::resizeComplex_data() const
{
- QTest::addColumn<QVector<Custom> >("vector");
+ QTest::addColumn<QList<Custom> >("vector");
QTest::addColumn<int>("size");
QVERIFY(QTypeInfo<Custom>::isComplex);
QVERIFY(QTypeInfo<Custom>::isStatic);
- QVector<Custom> null;
- QVector<Custom> empty(0, '0');
- QVector<Custom> emptyReserved;
- QVector<Custom> nonEmpty;
- QVector<Custom> nonEmptyReserved;
+ QList<Custom> null;
+ QList<Custom> empty(0, '0');
+ QList<Custom> emptyReserved;
+ QList<Custom> nonEmpty;
+ QList<Custom> nonEmptyReserved;
emptyReserved.reserve(10);
nonEmptyReserved.reserve(15);
@@ -2039,11 +2039,11 @@ void tst_QVector::resizeComplex_data() const
QTest::newRow("nonEmptyReserved") << nonEmptyReserved << 10;
}
-void tst_QVector::resizeComplex() const
+void tst_QList::resizeComplex() const
{
const int items = Custom::counter.loadAcquire();
{
- QFETCH(QVector<Custom>, vector);
+ QFETCH(QList<Custom>, vector);
QFETCH(int, size);
int oldSize = vector.size();
@@ -2063,15 +2063,15 @@ void tst_QVector::resizeComplex() const
QCOMPARE(Custom::counter.loadAcquire(), items);
}
-void tst_QVector::resizeCtorAndDtor() const
+void tst_QList::resizeCtorAndDtor() const
{
const int items = Custom::counter.loadAcquire();
{
- QVector<Custom> null;
- QVector<Custom> empty(0, '0');
- QVector<Custom> emptyReserved;
- QVector<Custom> nonEmpty;
- QVector<Custom> nonEmptyReserved;
+ QList<Custom> null;
+ QList<Custom> empty(0, '0');
+ QList<Custom> emptyReserved;
+ QList<Custom> nonEmpty;
+ QList<Custom> nonEmptyReserved;
emptyReserved.reserve(10);
nonEmptyReserved.reserve(15);
@@ -2090,13 +2090,13 @@ void tst_QVector::resizeCtorAndDtor() const
QCOMPARE(Custom::counter.loadAcquire(), items);
}
-void tst_QVector::reverseIterators() const
+void tst_QList::reverseIterators() const
{
- QVector<int> v;
+ QList<int> v;
v << 1 << 2 << 3 << 4;
- QVector<int> vr = v;
+ QList<int> vr = v;
std::reverse(vr.begin(), vr.end());
- const QVector<int> &cvr = vr;
+ const QList<int> &cvr = vr;
QVERIFY(std::equal(v.begin(), v.end(), vr.rbegin()));
QVERIFY(std::equal(v.begin(), v.end(), vr.crbegin()));
QVERIFY(std::equal(v.begin(), v.end(), cvr.rbegin()));
@@ -2106,10 +2106,10 @@ void tst_QVector::reverseIterators() const
}
template<typename T>
-void tst_QVector::size() const
+void tst_QList::size() const
{
// zero size
- QVector<T> myvec;
+ QList<T> myvec;
QVERIFY(myvec.size() == 0);
// grow
@@ -2125,19 +2125,19 @@ void tst_QVector::size() const
QVERIFY(myvec.size() == 0);
}
-void tst_QVector::sizeInt() const
+void tst_QList::sizeInt() const
{
size<int>();
}
-void tst_QVector::sizeMovable() const
+void tst_QList::sizeMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
size<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::sizeCustom() const
+void tst_QList::sizeCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
size<Custom>();
@@ -2146,9 +2146,9 @@ void tst_QVector::sizeCustom() const
// ::squeeze() is tested in ::capacity().
-void tst_QVector::startsWith() const
+void tst_QList::startsWith() const
{
- QVector<int> myvec;
+ QList<int> myvec;
// empty vector
QVERIFY(!myvec.startsWith(1));
@@ -2167,9 +2167,9 @@ void tst_QVector::startsWith() const
}
template<typename T>
-void tst_QVector::swap() const
+void tst_QList::swap() const
{
- QVector<T> v1, v2;
+ QList<T> v1, v2;
T val1 = SimpleValue<T>::at(0);
T val2 = SimpleValue<T>::at(1);
T val3 = SimpleValue<T>::at(2);
@@ -2180,43 +2180,43 @@ void tst_QVector::swap() const
v2 << val4 << val5 << val6;
v1.swap(v2);
- QCOMPARE(v1,QVector<T>() << val4 << val5 << val6);
- QCOMPARE(v2,QVector<T>() << val1 << val2 << val3);
+ QCOMPARE(v1,QList<T>() << val4 << val5 << val6);
+ QCOMPARE(v2,QList<T>() << val1 << val2 << val3);
}
-void tst_QVector::swapInt() const
+void tst_QList::swapInt() const
{
swap<int>();
}
-void tst_QVector::swapMovable() const
+void tst_QList::swapMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
swap<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::swapCustom() const
+void tst_QList::swapCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
swap<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::toList() const
+void tst_QList::toList() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C";
// make sure it converts and doesn't modify the original vector
QCOMPARE(myvec.toList(), QList<QString>() << "A" << "B" << "C");
- QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C");
+ QCOMPARE(myvec, QList<QString>() << "A" << "B" << "C");
}
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
-void tst_QVector::toStdVector() const
+void tst_QList::toStdVector() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C";
std::vector<QString> svec = myvec.toStdVector();
@@ -2224,13 +2224,13 @@ void tst_QVector::toStdVector() const
QCOMPARE(svec.at(1), QLatin1String("B"));
QCOMPARE(svec.at(2), QLatin1String("C"));
- QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C");
+ QCOMPARE(myvec, QList<QString>() << "A" << "B" << "C");
}
#endif
-void tst_QVector::value() const
+void tst_QList::value() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C";
// valid calls
@@ -2252,13 +2252,13 @@ void tst_QVector::value() const
QCOMPARE(myvec.value(3, QLatin1String("default")), QLatin1String("default"));
}
-void tst_QVector::testOperators() const
+void tst_QList::testOperators() const
{
- QVector<QString> myvec;
+ QList<QString> myvec;
myvec << "A" << "B" << "C";
- QVector<QString> myvectwo;
+ QList<QString> myvectwo;
myvectwo << "D" << "E" << "F";
- QVector<QString> combined;
+ QList<QString> combined;
combined << "A" << "B" << "C" << "D" << "E" << "F";
// !=
@@ -2266,8 +2266,8 @@ void tst_QVector::testOperators() const
// +
QCOMPARE(myvec + myvectwo, combined);
- QCOMPARE(myvec, QVector<QString>() << "A" << "B" << "C");
- QCOMPARE(myvectwo, QVector<QString>() << "D" << "E" << "F");
+ QCOMPARE(myvec, QList<QString>() << "A" << "B" << "C");
+ QCOMPARE(myvectwo, QList<QString>() << "D" << "E" << "F");
// +=
myvec += myvectwo;
@@ -2314,15 +2314,15 @@ struct Foo
~Foo() { delete p; ++fooDtor; }
};
-void tst_QVector::reserve()
+void tst_QList::reserve()
{
fooCtor = 0;
fooDtor = 0;
{
- QVector<Foo> a;
+ QList<Foo> a;
a.resize(2);
QCOMPARE(fooCtor, 2);
- QVector<Foo> b(a);
+ QList<Foo> b(a);
b.reserve(1);
QCOMPARE(b.size(), a.size());
QCOMPARE(fooDtor, 0);
@@ -2331,9 +2331,9 @@ void tst_QVector::reserve()
}
// This is a regression test for QTBUG-51758
-void tst_QVector::reserveZero()
+void tst_QList::reserveZero()
{
- QVector<int> vec;
+ QList<int> vec;
vec.detach();
vec.reserve(0); // should not crash
QCOMPARE(vec.size(), 0);
@@ -2350,57 +2350,57 @@ void tst_QVector::reserveZero()
}
template<typename T>
-void tst_QVector::initializeList()
+void tst_QList::initializeList()
{
T val1(SimpleValue<T>::at(1));
T val2(SimpleValue<T>::at(2));
T val3(SimpleValue<T>::at(3));
T val4(SimpleValue<T>::at(4));
- QVector<T> v1 {val1, val2, val3};
- QCOMPARE(v1, QVector<T>() << val1 << val2 << val3);
- QCOMPARE(v1, (QVector<T> {val1, val2, val3}));
+ QList<T> v1 {val1, val2, val3};
+ QCOMPARE(v1, QList<T>() << val1 << val2 << val3);
+ QCOMPARE(v1, (QList<T> {val1, val2, val3}));
- QVector<QVector<T>> v2{ v1, {val4}, QVector<T>(), {val1, val2, val3} };
- QVector<QVector<T>> v3;
- v3 << v1 << (QVector<T>() << val4) << QVector<T>() << v1;
+ QList<QList<T>> v2{ v1, {val4}, QList<T>(), {val1, val2, val3} };
+ QList<QList<T>> v3;
+ v3 << v1 << (QList<T>() << val4) << QList<T>() << v1;
QCOMPARE(v3, v2);
- QVector<T> v4({});
+ QList<T> v4({});
QCOMPARE(v4.size(), 0);
}
-void tst_QVector::initializeListInt()
+void tst_QList::initializeListInt()
{
initializeList<int>();
}
-void tst_QVector::initializeListMovable()
+void tst_QList::initializeListMovable()
{
const int instancesCount = Movable::counter.loadAcquire();
initializeList<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::initializeListCustom()
+void tst_QList::initializeListCustom()
{
const int instancesCount = Custom::counter.loadAcquire();
initializeList<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-void tst_QVector::const_shared_null()
+void tst_QList::const_shared_null()
{
- QVector<int> v2;
+ QList<int> v2;
QVERIFY(!v2.isDetached());
}
template<typename T>
-void tst_QVector::detach() const
+void tst_QList::detach() const
{
{
// detach an empty vector
- QVector<T> v;
+ QList<T> v;
v.detach();
QVERIFY(!v.isDetached());
QCOMPARE(v.size(), 0);
@@ -2408,8 +2408,8 @@ void tst_QVector::detach() const
}
{
// detach an empty referenced vector
- QVector<T> v;
- QVector<T> ref(v);
+ QList<T> v;
+ QList<T> ref(v);
QVERIFY(!v.isDetached());
v.detach();
QVERIFY(!v.isDetached());
@@ -2418,8 +2418,8 @@ void tst_QVector::detach() const
}
{
// detach a not empty referenced vector
- QVector<T> v(31);
- QVector<T> ref(v);
+ QList<T> v(31);
+ QList<T> ref(v);
QVERIFY(!v.isDetached());
v.detach();
QVERIFY(v.isDetached());
@@ -2428,7 +2428,7 @@ void tst_QVector::detach() const
}
{
// detach a not empty vector
- QVector<T> v(31);
+ QList<T> v(31);
QVERIFY(v.isDetached());
v.detach(); // detaching a detached vector
QVERIFY(v.isDetached());
@@ -2437,9 +2437,9 @@ void tst_QVector::detach() const
}
{
// detach a not empty vector with preallocated space
- QVector<T> v(3);
+ QList<T> v(3);
v.reserve(8);
- QVector<T> ref(v);
+ QList<T> ref(v);
QVERIFY(!v.isDetached());
v.detach();
QVERIFY(v.isDetached());
@@ -2448,7 +2448,7 @@ void tst_QVector::detach() const
}
{
// detach a not empty vector with preallocated space
- QVector<T> v(3);
+ QList<T> v(3);
v.reserve(8);
QVERIFY(v.isDetached());
v.detach(); // detaching a detached vector
@@ -2458,8 +2458,8 @@ void tst_QVector::detach() const
}
{
// detach a not empty, initialized vector
- QVector<T> v(7, SimpleValue<T>::at(1));
- QVector<T> ref(v);
+ QList<T> v(7, SimpleValue<T>::at(1));
+ QList<T> ref(v);
QVERIFY(!v.isDetached());
v.detach();
QVERIFY(v.isDetached());
@@ -2469,7 +2469,7 @@ void tst_QVector::detach() const
}
{
// detach a not empty, initialized vector
- QVector<T> v(7, SimpleValue<T>::at(2));
+ QList<T> v(7, SimpleValue<T>::at(2));
QVERIFY(v.isDetached());
v.detach(); // detaching a detached vector
QVERIFY(v.isDetached());
@@ -2479,9 +2479,9 @@ void tst_QVector::detach() const
}
{
// detach a not empty, initialized vector with preallocated space
- QVector<T> v(7, SimpleValue<T>::at(3));
+ QList<T> v(7, SimpleValue<T>::at(3));
v.reserve(31);
- QVector<T> ref(v);
+ QList<T> ref(v);
QVERIFY(!v.isDetached());
v.detach();
QVERIFY(v.isDetached());
@@ -2492,47 +2492,47 @@ void tst_QVector::detach() const
}
}
-void tst_QVector::detachInt() const
+void tst_QList::detachInt() const
{
detach<int>();
}
-void tst_QVector::detachMovable() const
+void tst_QList::detachMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
detach<Movable>();
QCOMPARE(instancesCount, Movable::counter.loadAcquire());
}
-void tst_QVector::detachCustom() const
+void tst_QList::detachCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
detach<Custom>();
QCOMPARE(instancesCount, Custom::counter.loadAcquire());
}
-static QAtomicPointer<QVector<int> > detachThreadSafetyDataInt;
-static QAtomicPointer<QVector<Movable> > detachThreadSafetyDataMovable;
-static QAtomicPointer<QVector<Custom> > detachThreadSafetyDataCustom;
+static QAtomicPointer<QList<int> > detachThreadSafetyDataInt;
+static QAtomicPointer<QList<Movable> > detachThreadSafetyDataMovable;
+static QAtomicPointer<QList<Custom> > detachThreadSafetyDataCustom;
-template<typename T> QAtomicPointer<QVector<T> > *detachThreadSafetyData();
-template<> QAtomicPointer<QVector<int> > *detachThreadSafetyData() { return &detachThreadSafetyDataInt; }
-template<> QAtomicPointer<QVector<Movable> > *detachThreadSafetyData() { return &detachThreadSafetyDataMovable; }
-template<> QAtomicPointer<QVector<Custom> > *detachThreadSafetyData() { return &detachThreadSafetyDataCustom; }
+template<typename T> QAtomicPointer<QList<T> > *detachThreadSafetyData();
+template<> QAtomicPointer<QList<int> > *detachThreadSafetyData() { return &detachThreadSafetyDataInt; }
+template<> QAtomicPointer<QList<Movable> > *detachThreadSafetyData() { return &detachThreadSafetyDataMovable; }
+template<> QAtomicPointer<QList<Custom> > *detachThreadSafetyData() { return &detachThreadSafetyDataCustom; }
static QSemaphore detachThreadSafetyLock;
template<typename T>
-void tst_QVector::detachThreadSafety() const
+void tst_QList::detachThreadSafety() const
{
- delete detachThreadSafetyData<T>()->fetchAndStoreOrdered(new QVector<T>(SimpleValue<T>::vector(400)));
+ delete detachThreadSafetyData<T>()->fetchAndStoreOrdered(new QList<T>(SimpleValue<T>::vector(400)));
static const uint threadsCount = 5;
struct : QThread {
void run() override
{
- QVector<T> copy(*detachThreadSafetyData<T>()->loadRelaxed());
+ QList<T> copy(*detachThreadSafetyData<T>()->loadRelaxed());
QVERIFY(!copy.isDetached());
detachThreadSafetyLock.release();
detachThreadSafetyLock.acquire(100);
@@ -2556,13 +2556,13 @@ void tst_QVector::detachThreadSafety() const
threads[i].wait();
}
-void tst_QVector::detachThreadSafetyInt() const
+void tst_QList::detachThreadSafetyInt() const
{
for (uint i = 0; i < 128; ++i)
detachThreadSafety<int>();
}
-void tst_QVector::detachThreadSafetyMovable() const
+void tst_QList::detachThreadSafetyMovable() const
{
const int instancesCount = Movable::counter.loadAcquire();
for (uint i = 0; i < 128; ++i) {
@@ -2571,7 +2571,7 @@ void tst_QVector::detachThreadSafetyMovable() const
}
}
-void tst_QVector::detachThreadSafetyCustom() const
+void tst_QList::detachThreadSafetyCustom() const
{
const int instancesCount = Custom::counter.loadAcquire();
for (uint i = 0; i < 128; ++i) {
@@ -2580,11 +2580,11 @@ void tst_QVector::detachThreadSafetyCustom() const
}
}
-void tst_QVector::insertMove() const
+void tst_QList::insertMove() const
{
const int instancesCount = Movable::counter.loadAcquire();
{
- QVector<Movable> vec;
+ QList<Movable> vec;
vec.reserve(7);
Movable m0;
Movable m1;
@@ -2642,9 +2642,9 @@ void tst_QVector::insertMove() const
QCOMPARE(Movable::counter.loadAcquire(), instancesCount);
}
-void tst_QVector::swapItemsAt() const
+void tst_QList::swapItemsAt() const
{
- QVector<int> v;
+ QList<int> v;
v << 0 << 1 << 2 << 3;
v.swapItemsAt(0, 2);
@@ -2659,72 +2659,72 @@ void tst_QVector::swapItemsAt() const
QCOMPARE(copy.at(2), 2);
}
-void tst_QVector::emplaceInt()
+void tst_QList::emplaceInt()
{
emplaceImpl<int>();
}
-void tst_QVector::emplaceCustom()
+void tst_QList::emplaceCustom()
{
emplaceImpl<Custom>();
}
-void tst_QVector::emplaceMovable()
+void tst_QList::emplaceMovable()
{
emplaceImpl<Movable>();
}
-void tst_QVector::emplaceConsistentWithStdVectorInt()
+void tst_QList::emplaceConsistentWithStdVectorInt()
{
emplaceConsistentWithStdVectorImpl<int>();
}
-void tst_QVector::emplaceConsistentWithStdVectorCustom()
+void tst_QList::emplaceConsistentWithStdVectorCustom()
{
emplaceConsistentWithStdVectorImpl<Custom>();
}
-void tst_QVector::emplaceConsistentWithStdVectorMovable()
+void tst_QList::emplaceConsistentWithStdVectorMovable()
{
emplaceConsistentWithStdVectorImpl<Movable>();
}
-void tst_QVector::emplaceReturnsIterator()
+void tst_QList::emplaceReturnsIterator()
{
- QVector<Movable> vec;
+ QList<Movable> vec;
vec.emplace(0, 'k')->i = 'p';
QCOMPARE(vec[0].i, 'p');
}
-void tst_QVector::emplaceBack()
+void tst_QList::emplaceBack()
{
QScopedValueRollback<QAtomicInt> rollback(Movable::counter, 0);
- QVector<Movable> vec;
+ QList<Movable> vec;
vec.emplaceBack('k');
QCOMPARE(Movable::counter, 1);
}
-void tst_QVector::emplaceBackReturnsRef()
+void tst_QList::emplaceBackReturnsRef()
{
- QVector<Movable> vec;
+ QList<Movable> vec;
vec.emplaceBack('k').i = 'p';
QCOMPARE(vec.at(0).i, 'p');
}
-void tst_QVector::emplaceWithElementFromTheSameContainer()
+void tst_QList::emplaceWithElementFromTheSameContainer()
{
QFETCH(int, elementPos);
QFETCH(int, insertPos);
QFETCH(bool, doCopy);
- QVector<QString> vec {"a", "b", "c", "d", "e"};
+ QList<QString> vec {"a", "b", "c", "d", "e"};
const QString e = vec[elementPos];
if (doCopy)
@@ -2735,7 +2735,7 @@ void tst_QVector::emplaceWithElementFromTheSameContainer()
QCOMPARE(vec[insertPos], e);
}
-void tst_QVector::emplaceWithElementFromTheSameContainer_data()
+void tst_QList::emplaceWithElementFromTheSameContainer_data()
{
QTest::addColumn<int>("elementPos");
QTest::addColumn<int>("insertPos");
@@ -2755,9 +2755,9 @@ void tst_QVector::emplaceWithElementFromTheSameContainer_data()
}
template<typename T>
-void tst_QVector::emplaceImpl() const
+void tst_QList::emplaceImpl() const
{
- QVector<T> vec {'a', 'b', 'c', 'd'};
+ QList<T> vec {'a', 'b', 'c', 'd'};
vec.emplace(2, 'k');
@@ -2765,23 +2765,23 @@ void tst_QVector::emplaceImpl() const
}
template <class T>
-static void vecEq(const QVector<T> &qVec, const std::vector<T> &stdVec)
+static void vecEq(const QList<T> &qVec, const std::vector<T> &stdVec)
{
QCOMPARE(std::size_t(qVec.size()), stdVec.size());
QVERIFY(std::equal(qVec.begin(), qVec.end(), stdVec.begin(), stdVec.end()));
}
template <class T>
-static void squeezeVec(QVector<T> &qVec, std::vector<T> &stdVec)
+static void squeezeVec(QList<T> &qVec, std::vector<T> &stdVec)
{
qVec.squeeze();
stdVec.shrink_to_fit();
}
template<typename T>
-void tst_QVector::emplaceConsistentWithStdVectorImpl() const
+void tst_QList::emplaceConsistentWithStdVectorImpl() const
{
- QVector<T> qVec {'a', 'b', 'c', 'd', 'e'};
+ QList<T> qVec {'a', 'b', 'c', 'd', 'e'};
std::vector<T> stdVec {'a', 'b', 'c', 'd', 'e'};
vecEq(qVec, stdVec);
@@ -2830,5 +2830,5 @@ void tst_QVector::emplaceConsistentWithStdVectorImpl() const
vecEq(qVec, stdVec);
}
-QTEST_MAIN(tst_QVector)
-#include "tst_qvector.moc"
+QTEST_MAIN(tst_QList)
+#include "tst_qlist.moc"
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index 21dfdf8c47..0557b69e5c 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -16,6 +16,7 @@ SUBDIRS=\
qhash \
qhashfunctions \
qline \
+ qlist \
qmakearray \
qmap \
qmargins \
@@ -38,7 +39,6 @@ SUBDIRS=\
qstl \
qtimeline \
qvarlengtharray \
- qvector \
qversionnumber
darwin: SUBDIRS += qmacautoreleasepool
diff --git a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
index ec3e71ac8f..4b926dcd05 100644
--- a/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
+++ b/tests/auto/dbus/qdbusmetatype/tst_qdbusmetatype.cpp
@@ -402,7 +402,7 @@ void tst_QDBusMetaType::invalidTypes()
else if (qstrcmp(QTest::currentDataTag(), "Invalid7") == 0)
QTest::ignoreMessage(QtWarningMsg, "QDBusMarshaller: type `Invalid7' produces invalid D-BUS signature `()' (Did you forget to call beginStructure() ?)");
else if (qstrcmp(QTest::currentDataTag(), "QList<Invalid0>") == 0)
- QTest::ignoreMessage(QtWarningMsg, "QDBusMarshaller: type `QVector<Invalid0>' produces invalid D-BUS signature `a' (Did you forget to call beginStructure() ?)");
+ QTest::ignoreMessage(QtWarningMsg, "QDBusMarshaller: type `QList<Invalid0>' produces invalid D-BUS signature `a' (Did you forget to call beginStructure() ?)");
staticTypes();
staticTypes(); // run twice: the error messages should be printed once only
diff --git a/tests/auto/tools/moc/allmocs_baseline_in.json b/tests/auto/tools/moc/allmocs_baseline_in.json
index 7b025963e2..85751845c4 100644
--- a/tests/auto/tools/moc/allmocs_baseline_in.json
+++ b/tests/auto/tools/moc/allmocs_baseline_in.json
@@ -1251,7 +1251,7 @@
"required": false,
"scriptable": true,
"stored": true,
- "type": "QVector<Foo::Bar::Flags>",
+ "type": "QList<Foo::Bar::Flags>",
"user": false,
"write": "setFlagsList"
}
@@ -2699,7 +2699,7 @@
"access": "public",
"arguments": [
{
- "type": "QVector<QVector<int>>"
+ "type": "QList<QList<int>>"
}
],
"name": "foo",
@@ -2709,7 +2709,7 @@
"access": "public",
"arguments": [
{
- "type": "QVector<QVector<int>>"
+ "type": "QList<QList<int>>"
}
],
"name": "foo2",
@@ -2719,7 +2719,7 @@
"access": "public",
"arguments": [
{
- "type": "QVector<::AAA::BaseA*>"
+ "type": "QList<::AAA::BaseA*>"
}
],
"name": "bar",
@@ -2729,7 +2729,7 @@
"access": "public",
"arguments": [
{
- "type": "QVector<::AAA::BaseA*>"
+ "type": "QList<::AAA::BaseA*>"
}
],
"name": "bar2",
@@ -2739,7 +2739,7 @@
"access": "public",
"arguments": [
{
- "type": "QVector<const ::AAA::BaseA*>"
+ "type": "QList<const ::AAA::BaseA*>"
}
],
"name": "bar3",
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index 4a6d16b45a..05ad63e4ba 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -1804,32 +1804,16 @@ signals:
class QTBUG12260_defaultTemplate_Object : public QObject
{ Q_OBJECT
public slots:
-#if !(defined(Q_CC_GNU) && __GNUC__ == 4 && __GNUC_MINOR__ <= 3) || defined(Q_MOC_RUN)
void doSomething(QHash<QString, QVariant> values = QHash<QString, QVariant>() ) { Q_UNUSED(values); }
void doSomethingElse(QSharedPointer<QVarLengthArray<QString, (16 >> 2)> > val
= QSharedPointer<QVarLengthArray<QString, (16 >> 2)> >() )
{ Q_UNUSED(val); }
-#else
- // we want to test the previous function, but gcc < 4.4 seemed to have a bug similar to the one moc has.
- typedef QHash<QString, QVariant> WorkaroundGCCBug;
- void doSomething(QHash<QString, QVariant> values = WorkaroundGCCBug() ) { Q_UNUSED(values); }
- void doSomethingElse(QSharedPointer<QVarLengthArray<QString, (16 >> 2)> > val
- = (QSharedPointer<QVarLengthArray<QString, (16 >> 2)> >()) )
- { Q_UNUSED(val); }
-#endif
void doAnotherThing(bool a = (1 < 3), bool b = (1 > 4)) { Q_UNUSED(a); Q_UNUSED(b); }
-#if defined(Q_MOC_RUN) || (defined(Q_COMPILER_AUTO_TYPE) && !(defined(Q_CC_CLANG) && Q_CC_CLANG < 304))
- // There is no Q_COMPILER_>> but if compiler support auto, it should also support >>
- void performSomething(QVector<QList<QString>> e = QVector<QList<QString>>(8 < 1),
- QHash<int, QVector<QString>> h = QHash<int, QVector<QString>>())
+ void performSomething(QList<QList<QString>> e = QList<QList<QString>>(8 < 1),
+ QHash<int, QList<QString>> h = QHash<int, QList<QString>>())
{ Q_UNUSED(e); Q_UNUSED(h); }
-#else
- void performSomething(QVector<QList<QString> > e = QVector<QList<QString> >(),
- QHash<int, QVector<QString> > h = (QHash<int, QVector<QString> >()))
- { Q_UNUSED(e); Q_UNUSED(h); }
-#endif
};
@@ -1838,7 +1822,7 @@ void tst_Moc::QTBUG12260_defaultTemplate()
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomething(QHash<QString,QVariant>)") != -1);
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doAnotherThing(bool,bool)") != -1);
QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("doSomethingElse(QSharedPointer<QVarLengthArray<QString,(16>>2)>>)") != -1);
- QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("performSomething(QVector<QList<QString>>,QHash<int,QVector<QString>>)") != -1);
+ QVERIFY(QTBUG12260_defaultTemplate_Object::staticMetaObject.indexOfSlot("performSomething(QList<QList<QString>>,QHash<int,QList<QString>>)") != -1);
}
void tst_Moc::notifyError()