diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-12-01 09:25:50 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2022-12-02 20:53:02 +0100 |
commit | f6b137bdc43d4021cbbe602759dbcced2e04d638 (patch) | |
tree | 2c2a076d005b1fc05fad2815a0b6bc3231f3085c /src/corelib/doc | |
parent | 93f54f0aa44467da1ea7ef7bcb01e891c619c8f5 (diff) |
Brush up the container documentation
Make the code snippets consistent, update the comparison table
and fix some sentences.
Pick-to: 6.4 6.2
Change-Id: Ic8baaa56805392855736164efa03d065330309fa
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/doc')
-rw-r--r-- | src/corelib/doc/snippets/code/doc_src_containers.cpp | 12 | ||||
-rw-r--r-- | src/corelib/doc/src/containers.qdoc | 17 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_containers.cpp b/src/corelib/doc/snippets/code/doc_src_containers.cpp index 29d9b584d0..680a099f68 100644 --- a/src/corelib/doc/snippets/code/doc_src_containers.cpp +++ b/src/corelib/doc/snippets/code/doc_src_containers.cpp @@ -247,9 +247,9 @@ target_compile_definitions(my_app PRIVATE QT_NO_KEYWORDS) QString onlyLetters(const QString &in) { QString out; - for (int j = 0; j < in.size(); ++j) { - if (in[j].isLetter()) - out += in[j]; + for (qsizetype j = 0; j < in.size(); ++j) { + if (in.at(j).isLetter()) + out += in.at(j); } return out; } @@ -286,15 +286,15 @@ int j = *i; // Undefined behavior! //! [24] //! [25] -QList<int> list { 1, 2, 3, 4, 4, 5 }; -QSet<int> set(list.begin(), list.end()); +QList<int> list = {1, 2, 3, 4, 4, 5}; +QSet<int> set(list.cbegin(), list.cend()); /* Will generate a QSet containing 1, 2, 3, 4, 5. */ //! [25] //! [26] -QList<int> list { 2, 3, 1 }; +QList<int> list = {2, 3, 1}; std::sort(list.begin(), list.end()); /* diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index b5f4029fbe..4a7d5dc1bb 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -39,7 +39,8 @@ \note Since Qt 5.14, range constructors are available for most of the container classes. QMultiMap is a notable exception. Their use is - encouraged in place of the various from/to methods. For example: + encouraged to replace of the various deprecated from/to methods of Qt 5. + For example: \snippet code/doc_src_containers.cpp 25 @@ -285,12 +286,10 @@ In the code snippets so far, we used the unary \c * operator to retrieve the item (of type QString) stored at a certain iterator - position, and we then called QString::toLower() on it. Most C++ - compilers also allow us to write \c{i->toLower()}, but some - don't. + position, and we then called QString::toLower() on it. - For read-only access, you can use const_iterator, \l{QList::constBegin}{constBegin()}, - and \l{QList::constEnd()}{constEnd()}. For example: + For read-only access, you can use const_iterator, \l{QList::cbegin}{cbegin()}, + and \l{QList::cend()}{cend()}. For example: \snippet code/doc_src_containers.cpp 12 @@ -384,7 +383,7 @@ \li Similar to std::queue<T>, inherits from \l{QList}. \row \li \l{QSet}<T> - \li Similar to std::set<T>. Internally, \l{QSet} is implemented with a + \li Similar to std::unordered_set<T>. Internally, \l{QSet} is implemented with a \l{QHash}. \row \li \l{QMap}<Key, T> @@ -394,10 +393,10 @@ \li Similar to std::multimap<T>. \row \li \l{QHash}<Key, T> - \li Most similar to std::map<T>. + \li Most similar to std::unordered_map<T>. \row \li \l{QMultiHash}<Key, T> - \li Most similar to std::multimap<T>. + \li Most similar to std::unordered_multimap<T>. \endtable |