summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2019-06-20 17:40:45 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2019-06-29 21:58:36 +0200
commitff2b2032a089d74975da4a3fac7c7c90989e6dc5 (patch)
tree2c2930d5e38fb3f94a936e5a0c8bc2c4e5259dbb
parentfabf9239e0e6231f09d4a324bfe85ffcc529da3d (diff)
Remove usages of deprecated APIs from QtAlgorithms
Task-number: QTBUG-76491 Change-Id: I9dab736a0cbd2e86588919640c26e8ce6b3674d0 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
-rw-r--r--src/corelib/doc/snippets/code/doc_src_qset.cpp6
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp8
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp2
-rw-r--r--src/corelib/doc/src/containers.qdoc2
-rw-r--r--src/corelib/tools/qlinkedlist.cpp6
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc2
-rw-r--r--tests/auto/corelib/io/largefile/tst_largefile.cpp1
-rw-r--r--tests/auto/corelib/tools/collections/tst_collections.cpp23
-rw-r--r--tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp2
-rw-r--r--tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp2
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp2
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp6
-rw-r--r--tests/benchmarks/corelib/tools/qvector/qrawvector.h7
-rw-r--r--tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp2
-rw-r--r--tests/manual/socketengine/main.cpp2
-rw-r--r--util/glgen/codegenerator.cpp2
-rw-r--r--util/glgen/legacyspecparser.cpp2
-rw-r--r--util/lexgen/generator.cpp6
-rw-r--r--util/lexgen/nfa.cpp2
-rw-r--r--util/unicode/codecs/big5/main.cpp4
-rw-r--r--util/unicode/main.cpp4
21 files changed, 35 insertions, 58 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_qset.cpp b/src/corelib/doc/snippets/code/doc_src_qset.cpp
index 7f7cec8b45..4248c49642 100644
--- a/src/corelib/doc/snippets/code/doc_src_qset.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_qset.cpp
@@ -131,7 +131,7 @@ while (i != set.end()) {
//! [10]
QSet<QString> set;
...
-QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
+QSet<QString>::iterator it = std::find(set.begin(), set.end(), "Jeanette");
if (it != set.end())
cout << "Found Jeanette" << Qt::endl;
//! [10]
@@ -150,7 +150,7 @@ for (i = set.begin(); i != set.end(); ++i)
//! [12]
QSet<QString> set;
...
-QSet<QString>::iterator it = qFind(set.begin(), set.end(), "Jeanette");
+QSet<QString>::iterator it = std::find(set.begin(), set.end(), "Jeanette");
if (it != set.constEnd())
cout << "Found Jeanette" << Qt::endl;
//! [12]
@@ -161,7 +161,7 @@ QSet<QString> set;
set << "red" << "green" << "blue" << ... << "black";
QList<QString> list = set.toList();
-qSort(list);
+std::sort(list.begin(), list.end());
//! [13]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
index e0d3c71dc5..e8754a5f34 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlinkedlist.cpp
@@ -119,8 +119,8 @@ for (i = list.begin(); i != list.end(); ++i)
//! [8]
QLinkedList<QString> list;
...
-QLinkedList<QString>::iterator it = qFind(list.begin(),
- list.end(), "Joel");
+QLinkedList<QString>::iterator it = std::find(list.begin(),
+ list.end(), "Joel");
if (it != list.end())
cout << "Found Joel" << Qt::endl;
//! [8]
@@ -189,8 +189,8 @@ for (i = list.constBegin(); i != list.constEnd(); ++i)
//! [15]
QLinkedList<QString> list;
...
-QLinkedList<QString>::iterator it = qFind(list.constBegin(),
- list.constEnd(), "Joel");
+QLinkedList<QString>::const_iterator it = std::find(list.constBegin(),
+ list.constEnd(), "Joel");
if (it != list.constEnd())
cout << "Found Joel" << Qt::endl;
//! [15]
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
index a24e599f2f..38fa526ef4 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qlistdata.cpp
@@ -247,7 +247,7 @@ QSet<int> set;
set << 20 << 30 << 40 << ... << 70;
QList<int> list = QList<int>::fromSet(set);
-qSort(list);
+std::sort(list.begin(), list.end());
//! [23]
diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc
index e6c95129db..919533f651 100644
--- a/src/corelib/doc/src/containers.qdoc
+++ b/src/corelib/doc/src/containers.qdoc
@@ -666,7 +666,7 @@
\li \b{Logarithmic time:} O(log \e n). A function that runs in
logarithmic time is a function whose running time is
proportional to the logarithm of the number of items in the
- container. One example is qBinaryFind().
+ container. One example is the binary search algorithm.
\li \b{Linear time:} O(\e n). A function that runs in linear time
will execute in a time directly proportional to the number of
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index c0450f5cd8..d239fe0ef4 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -742,8 +742,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\snippet code/src_corelib_tools_qlinkedlist.cpp 7
STL-style iterators can be used as arguments to \l{generic
- algorithms}. For example, here's how to find an item in the list
- using the qFind() algorithm:
+ algorithms}. For example, here's how to find an item in the list:
\snippet code/src_corelib_tools_qlinkedlist.cpp 8
@@ -987,8 +986,7 @@ const QLinkedListData QLinkedListData::shared_null = {
\snippet code/src_corelib_tools_qlinkedlist.cpp 14
STL-style iterators can be used as arguments to \l{generic
- algorithms}. For example, here's how to find an item in the list
- using the qFind() algorithm:
+ algorithms}. For example, here's how to find an item in the list:
\snippet code/src_corelib_tools_qlinkedlist.cpp 15
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
index 9335ff78c9..236582ef3f 100644
--- a/src/widgets/doc/src/model-view-programming.qdoc
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -1912,7 +1912,7 @@
\section3 Custom sorting models
- QSortFilterProxyModel instances use Qt's built-in qStableSort() function to set up
+ QSortFilterProxyModel instances use std::stable_sort() function to set up
mappings between items in the source model and those in the proxy model, allowing a
sorted hierarchy of items to be exposed to views without modifying the structure of the
source model. To provide custom sorting behavior, reimplement the
diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp
index f459f62c91..e6d2f10c16 100644
--- a/tests/auto/corelib/io/largefile/tst_largefile.cpp
+++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp
@@ -28,7 +28,6 @@
#include <QTest>
-#include <QtAlgorithms>
#include <QFile>
#include <QFileInfo>
#include <QRandomGenerator>
diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp
index 2a8b264998..e2ce5cb9f9 100644
--- a/tests/auto/corelib/tools/collections/tst_collections.cpp
+++ b/tests/auto/corelib/tools/collections/tst_collections.cpp
@@ -67,7 +67,6 @@ void foo()
#include <algorithm>
-#include "qalgorithms.h"
#include "qbitarray.h"
#include "qbytearray.h"
#include "qcache.h"
@@ -191,16 +190,6 @@ void tst_Collections::list()
QVERIFY(list.size() == 6);
QVERIFY(list.end() - list.begin() == list.size());
-#if !defined(Q_CC_MSVC) && !defined(Q_CC_SUN)
- QVERIFY(std::binary_search(list.begin(), list.end(), 2) == true);
- QVERIFY(std::binary_search(list.begin(), list.end(), 9) == false);
-#endif
- QVERIFY(qBinaryFind(list.begin(), list.end(), 2) == list.begin() + 1);
- QVERIFY(qLowerBound(list.begin(), list.end(), 2) == list.begin() + 1);
- QVERIFY(qUpperBound(list.begin(), list.end(), 2) == list.begin() + 2);
- QVERIFY(qBinaryFind(list.begin(), list.end(), 9) == list.end());
- QVERIFY(qLowerBound(list.begin(), list.end(), 9) == list.end());
- QVERIFY(qUpperBound(list.begin(), list.end(), 9) == list.end());
{
int sum = 0;
QListIterator<int> i(list);
@@ -996,16 +985,8 @@ void tst_Collections::vector()
v.append(2);
QVERIFY(*v.begin() == 2);
v.prepend(1);
-
- v << 3 << 4 << 5 << 6;
- QVERIFY(std::binary_search(v.begin(), v.end(), 2) == true);
- QVERIFY(std::binary_search(v.begin(), v.end(), 9) == false);
- QVERIFY(qBinaryFind(v.begin(), v.end(), 2) == v.begin() + 1);
- QVERIFY(qLowerBound(v.begin(), v.end(), 2) == v.begin() + 1);
- QVERIFY(qUpperBound(v.begin(), v.end(), 2) == v.begin() + 2);
- QVERIFY(qBinaryFind(v.begin(), v.end(), 9) == v.end());
- QVERIFY(qLowerBound(v.begin(), v.end(), 9) == v.end());
- QVERIFY(qUpperBound(v.begin(), v.end(), 9) == v.end());
+ QVERIFY(*v.begin() == 1);
+ QVERIFY(*(v.begin() + 1) == 2);
v.clear();
v << 1 << 2 << 3;
diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
index 5701335b4a..a46011ff6c 100644
--- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
+++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp
@@ -192,7 +192,7 @@ static void doTestData(const QString &testString, const QList<int> &expectedBrea
// test toPreviousBoundary()
{
QList<int> expectedBreakPositionsRev = expectedBreakPositions;
- std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), qGreater<int>());
+ std::sort(expectedBreakPositionsRev.begin(), expectedBreakPositionsRev.end(), std::greater<int>());
QList<int> actualBreakPositions;
boundaryFinder.toEnd();
diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
index 9a4c560a08..87a47bd93b 100644
--- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
+++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
@@ -155,7 +155,7 @@ void tst_QKeyEvent::modifiers_data()
modifierCombinations.append(modifierCombination);
}
- qSort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier);
+ std::sort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier);
QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
foreach (const QVector<int> combination, modifierCombinations) {
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index f8b6bf064a..874468c954 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
@@ -86,7 +86,7 @@ static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntrie
static QChar macSymbolForQtKey(int key)
{
- const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key);
+ const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key);
if (i == MacSpecialKeyEntriesEnd)
return QChar();
return QChar(i->macSymbol);
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index b05f989b5c..4035dfbf5f 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -711,7 +711,7 @@ void tst_QSslSocket::sslErrors()
const auto socketSslErrors = socket->sslErrors();
for (const QSslError &err : socketSslErrors)
sslErrors << err.error();
- qSort(sslErrors);
+ std::sort(sslErrors.begin(), sslErrors.end());
QVERIFY(sslErrors.contains(QSslError::HostNameMismatch));
QVERIFY(sslErrors.contains(FLUKE_CERTIFICATE_ERROR));
@@ -721,7 +721,7 @@ void tst_QSslSocket::sslErrors()
const auto sslErrorsSpyErrors = qvariant_cast<QList<QSslError> >(qAsConst(sslErrorsSpy).first().first());
for (const QSslError &err : sslErrorsSpyErrors)
emittedErrors << err.error();
- qSort(emittedErrors);
+ std::sort(emittedErrors.begin(), emittedErrors.end());
QCOMPARE(sslErrors, emittedErrors);
// check the same errors were emitted by peerVerifyError
@@ -730,7 +730,7 @@ void tst_QSslSocket::sslErrors()
const QList<QVariantList> &peerVerifyList = peerVerifyErrorSpy;
for (const QVariantList &args : peerVerifyList)
peerErrors << qvariant_cast<QSslError>(args.first()).error();
- qSort(peerErrors);
+ std::sort(peerErrors.begin(), peerErrors.end());
QCOMPARE(sslErrors, peerErrors);
}
diff --git a/tests/benchmarks/corelib/tools/qvector/qrawvector.h b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
index c7173b5b8d..16a911c63a 100644
--- a/tests/benchmarks/corelib/tools/qvector/qrawvector.h
+++ b/tests/benchmarks/corelib/tools/qvector/qrawvector.h
@@ -32,7 +32,6 @@
#include <QtCore/qiterator.h>
#include <QtCore/qdebug.h>
#include <QtCore/qatomic.h>
-#include <QtCore/qalgorithms.h>
#include <QtCore/qlist.h>
#include <QtCore/private/qtools_p.h>
@@ -263,9 +262,9 @@ public:
//static QRawVector<T> fromList(const QList<T> &list);
static inline QRawVector<T> fromStdVector(const std::vector<T> &vector)
- { QRawVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
+ { QRawVector<T> tmp; std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
- { std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
+ { std::vector<T> tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
private:
T *allocate(int alloc);
@@ -568,7 +567,7 @@ typename QRawVector<T>::iterator QRawVector<T>::erase(iterator abegin, iterator
int l = int(aend - m_begin);
int n = l - f;
if (QTypeInfo<T>::isComplex) {
- qCopy(m_begin + l, m_begin + m_size, m_begin + f);
+ std::copy(m_begin + l, m_begin + m_size, m_begin + f);
T *i = m_begin + m_size;
T *b = m_begin + m_size - n;
while (i != b) {
diff --git a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
index b2f4cbd7ba..c182ef7ebf 100644
--- a/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/benchmarks/network/access/qnetworkreply/tst_qnetworkreply.cpp
@@ -908,7 +908,7 @@ void tst_qnetworkreply::httpsRequestChain()
qint64 average = (elapsed / count);
- qSort(helper.timeList);
+ std::sort(helper.timeList.begin(), helper.timeList.end());
qint64 median = helper.timeList.at(5);
qDebug() << "Total:" << elapsed << " Average:" << average << " Median:" << median;
diff --git a/tests/manual/socketengine/main.cpp b/tests/manual/socketengine/main.cpp
index 0d491e7350..3e3e7e53e5 100644
--- a/tests/manual/socketengine/main.cpp
+++ b/tests/manual/socketengine/main.cpp
@@ -83,7 +83,7 @@ int main(int argc, char**argv)
// disconnected
exit(0);
}
- qFill(buf, buf + bufsize, 0);
+ std::fill(buf, buf + bufsize, 0);
ret = socketEngine->read(buf, available);
if (ret > 0) {
printf("%s", buf);
diff --git a/util/glgen/codegenerator.cpp b/util/glgen/codegenerator.cpp
index 4627daa48b..08327a62f5 100644
--- a/util/glgen/codegenerator.cpp
+++ b/util/glgen/codegenerator.cpp
@@ -184,7 +184,7 @@ void CodeGenerator::writeCoreFactoryImplementation(const QString &fileName) cons
// Get the set of version functions classes we need to create
QList<Version> versions = m_parser->versions();
- qSort(versions.begin(), versions.end(), qGreater<Version>());
+ std::sort(m_versions.begin(), m_versions.end(), std::greater<Version>());
// Outout the #include statements
stream << QStringLiteral("#if !defined(QT_OPENGL_ES_2)") << endl;
diff --git a/util/glgen/legacyspecparser.cpp b/util/glgen/legacyspecparser.cpp
index 0f4d085bba..ab2c9495e7 100644
--- a/util/glgen/legacyspecparser.cpp
+++ b/util/glgen/legacyspecparser.cpp
@@ -291,7 +291,7 @@ void LegacySpecParser::parseFunctions(QTextStream &stream)
}
m_versions = versions.toList();
- qSort(m_versions);
+ std::sort(m_versions.begin(), m_versions.end());
}
bool LegacySpecParser::inDeprecationException(const QString &functionName) const
diff --git a/util/lexgen/generator.cpp b/util/lexgen/generator.cpp
index 481d586e73..3b966e025b 100644
--- a/util/lexgen/generator.cpp
+++ b/util/lexgen/generator.cpp
@@ -183,7 +183,7 @@ Generator::Generator(const DFA &_dfa, const Config &config)
: dfa(_dfa), cfg(config)
{
QList<InputType> lst = cfg.maxInputSet.toList();
- qSort(lst);
+ std::sort(lst.begin(), lst.end());
minInput = lst.first();
maxInput = lst.last();
@@ -230,7 +230,7 @@ static QVector<Generator::TransitionSequence> convertToSequences(const Transitio
return sequences;
QList<InputType> keys = transitions.keys();
- qSort(keys);
+ std::sort(keys.begin(), keys.end());
int i = 0;
Generator::TransitionSequence sequence;
sequence.first = keys.at(0);
@@ -359,7 +359,7 @@ void Generator::generateTransitions(CodeBlock &body, const TransitionMap &transi
}
} else {
QList<InputType> keys = transitions.keys();
- qSort(keys);
+ std::sort(keys.begin(), keys.end());
body << "switch (ch.unicode()) {";
body.indent();
diff --git a/util/lexgen/nfa.cpp b/util/lexgen/nfa.cpp
index 9047a17fde..f6e3a5c355 100644
--- a/util/lexgen/nfa.cpp
+++ b/util/lexgen/nfa.cpp
@@ -384,7 +384,7 @@ QSet<int> NFA::epsilonClosure(const QSet<int> &initialClosure) const
QStack<int> stateStack;
stateStack.resize(closure.count());
- qCopy(closure.constBegin(), closure.constEnd(), stateStack.begin());
+ std::copy(closure.constBegin(), closure.constEnd(), stateStack.begin());
while (!stateStack.isEmpty()) {
int t = stateStack.pop();
diff --git a/util/unicode/codecs/big5/main.cpp b/util/unicode/codecs/big5/main.cpp
index 142db74ffd..54d3839755 100644
--- a/util/unicode/codecs/big5/main.cpp
+++ b/util/unicode/codecs/big5/main.cpp
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
list += QByteArray(" { 0x" + QByteArray::number(m.b5, 16) + ", 0x" + QByteArray::number(m.uc, 16) + " }\n");;
}
QByteArray ba;
- qSort(list);
+ std::sort(list.begin(), list.end());
foreach(QByteArray a, list)
ba += a;
qDebug() << "struct B5Map b5_to_uc_map = {\n" << ba + "\n};";
@@ -138,7 +138,7 @@ int main(int argc, char **argv)
if (!b5_ok.contains(m.uc))
list += QByteArray(" { 0x" + QByteArray::number(m.uc, 16) + ", 0x" + QByteArray::number(m.b5, 16) + " }\n");;
ba = QByteArray();
- qSort(list);
+ std::sort(list.begin(), list.end());;
foreach(QByteArray a, list)
ba += a;
qDebug() << "struct B5Map uc_to_b5_map = {\n" << ba + "\n};";
diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp
index 8576f00e35..ec84667ee5 100644
--- a/util/unicode/main.cpp
+++ b/util/unicode/main.cpp
@@ -2832,7 +2832,7 @@ static QByteArray createLigatureInfo()
QList<Ligature> l = ligatureHashes.value(uc);
if (!l.isEmpty()) {
Q_ASSERT(!QChar::requiresSurrogates(uc));
- qSort(l); // needed for bsearch in ligatureHelper code
+ std::sort(l.begin(), l.end()); // needed for bsearch in ligatureHelper code
ligatures.append(l.size());
for (int j = 0; j < l.size(); ++j) {
@@ -2864,7 +2864,7 @@ static QByteArray createLigatureInfo()
QList<Ligature> l = ligatureHashes.value(uc);
if (!l.isEmpty()) {
Q_ASSERT(QChar::requiresSurrogates(uc));
- qSort(l); // needed for bsearch in ligatureHelper code
+ std::sort(l.begin(), l.end()); // needed for bsearch in ligatureHelper code
ligatures.append(l.size());
for (int j = 0; j < l.size(); ++j) {