summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlist.qdoc
Commit message (Collapse)AuthorAgeFilesLines
* Containers: add max_size()Giuseppe D'Angelo2024-02-271-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One more method for STL compatibility. This one is particularly subtle as it's required by the `reservable-container` concept: https://eel.is/c++draft/ranges#range.utility.conv.general-3 Without this concept, ranges::to won't reserve() before copying the elements (out of a sized range which isn't a common_range). Implementation notes: there were already a couple of constants denoting the maximum QByteArray and QString size. Centralize that implementation in QTypedArrayData, so that QList can use it too. The maximum allocation size (private constant) needs a even more central place so that even QVLA can use it. Lacking anything better, I've put it in qcontainerfwd.h. Since our containers aren't allocator-aware, I can make max_size() a static member, and replace the existing constants throughout the rest of qtbase. (I can't kill them yet as they're used by other submodules.) [ChangeLog][QtCore][QList] Added max_size(). [ChangeLog][QtCore][QString] Added max_size(). [ChangeLog][QtCore][QByteArray] Added max_size(). [ChangeLog][QtCore][QVarLengthArray] Added max_size(). Change-Id: I176142e31b998f4f787c96333894b8f6653eb70d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: add uninitialized resizesGiuseppe D'Angelo2024-02-161-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Creating a QList of a given size, or resizing it to a given size, will always value-initialize its elements. This commit adds support for uninitialized construction and resizes. The intended use case is using a QList as storage-to-be-overwritten: QList<int> list(size, Qt::Uninitialized); fillWithData(list.data(), list.size); How do we define "uninitialized": 1) if T is constructible using Qt::Uninitialized, use that; 2) otherwise, default-construct T. In detail: 1) covers (Qt-ish) datatypes that have a default constructor that initializes them, but also a dedicated constructor that doesn't initialize (e.g. QPoint, QQuaternion, ...). 2) covers everything else. Default initialization of scalars and trivially constructible datatypes will leave them uninitialized. A type which isn't trivially constructible will still get its default constructor called (and possibly actually gets initialized); we can't really do better than that, as we still have to construct objects and start their lifetimes. [ChangeLog][QtCore][QList] Added support for uninitialized construction and resizing. Change-Id: I32c285c7dddbf7e01475943f24e14e824bb13090 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix \fn template arguments for Qt CoreLuca Di Sera2023-11-301-2/+2
| | | | | | | | | Upcoming changes to QDoc require accurate definition for template arguments in \fn commands. Task-number: QTBUG-118080 Change-Id: I64d50919bc6ffab61ef5ead553d1da99d63a9f21 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Fix template information for a QList constructorLuca Di Sera2023-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When QDoc parses a project, it parses the source code to extract the user-provided documentation and perform sanity checkings based on the code itself on it. When QDoc parses an "\fn" command as part of this process, it tries to understand, based on its intermediate representation built on the information extracted from the code-base, which "documentable element" the "\fn" refers to. When QDoc performs this "matching" process, it takes into consideration only a certain amount of information. For example, no checking is performed over the template declaration of a callable. Due to some upcoming documentation, where two callables are indistinguishable to the current process, as they differ only in their template declaration, QDoc will start to take into consideration the template declaration of a callable when matching. This implies that an "\fn" command should now provide information parity, with regards to template declaration for callables, with the code-base so that QDoc can perform the match correctly. The documentation for `QList::QList(InputIterator, InputIterator)` is not in sync with the intended target template declaration. Hence, add the missing information to the relevant "\fn" command. Task-number: QTBUG-118080 Change-Id: I576a3b71ba39cec0d51f08f7db9771401e1fa340 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Doc: Add missing return type to QList/QVarLengthArray::assignLuca Di Sera2023-10-131-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When QDoc reads an `\fn` command it saves it to a file to parse it with Clang, with the objective of using the produced AST to perform certain sanity checks on the documented element. Generally, `\fn` commands that do not represent correct C++ code with are accepted as long as Clang is still able to build an AST Node that QDoc can work with, not resulting in any issue in the output documentation. For example, an `\fn` that doesn't state a return type might be able to be parsed correctly enough by Clang to produce a sensible Node for the function that QDoc is interested into. The documentation for the various overloads for QList::assign and QVarLenghtArray::assign makes use of this possibility by not stating a return type. Up to Clang 15 this was not an issue, and a correct-enough AST was produced when the `\fn` commands for those methods were parsed. On Clang 16, Clang chokes on the missing return type, being unable to recognize the function definition and produce an AST that QDoc can work with. This has the effect of losing those documented element in the output documentation. To avoid the issue, a return type is now added to the relevant `\fn` commands. Change-Id: Ic1434aaf71c39840c64ce04fbd503c4542dc4f42 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QList/Doc: document the resize() overload taking a parameter_typeThiago Macieira2023-09-011-2/+3
| | | | | | | | | | Added by commit b42a2b3c3338a320a438bc081cb885fd4547f01f for 6.0, but we forgot to document it. Pick-to: 6.5 6.6 Change-Id: I2b24e1d3cad44897906efffd1780086b51c0e3fa Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Lars Knoll <lars@knoll.priv.no>
* QVarLengthArray/QList: make assign() return a reference to *thisMarc Mutz2023-05-171-3/+3
| | | | | | | | | | | | | While std::vector::assign() returns void, std::basic_string::assign() returns std::basic_string&. In Qt, we want to be consistent between {QVLA,QList,QString,QByteArray}::assign(), and returning *this is the more general solution, so do that. Task-number: QTBUG-106196 Task-number: QTBUG-106200 Change-Id: I2689b4af032ab6fb3f8fbcb4d825d5201ea5abeb Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QList: add STL-style assign()Dennis Oberst2023-05-161-1/+49
| | | | | | | | | | | | | | | Implemented assign() methods for QList to align with the criteria of std::vector, addressing the previously missing functionality. Reference: https://en.cppreference.com/w/cpp/container/vector/assign [ChangeLog][QtCore][QList] Added assign(). Fixes: QTBUG-106196 Change-Id: I5df8689c020dafde68d2cd7d09c769744fa8f137 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* [docs] QList: fix history of resize(n) semantics changeMarc Mutz2023-04-281-2/+7
| | | | | | | | | | | | | | | | | The description was copied from QVector, and doesn't exactly fit QList. For QList, the function is \since 6.0 when QList became QVector, not in Qt 5.7, as indicated. Be more precise. Amends 13293d3308c04d22bc2928e8991f47744560e085, which changed the docs for clear(). Pick-to: 6.5 6.2 Fixes: QTBUG-112334 Change-Id: I457a1f699ddcdcdad2f1daf88f577007c136ee8f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QString/QByteArray/QList: de-pessimize op+ [2/2]: overload on rvalue LHSMarc Mutz2022-12-071-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The + operator is left-associative, so a + b + c is (a + b) + c. Apply the same trick C++20 applied to std::string's op+ and overload for rvalue left-hand sides. This means that a + b + c is now equivalent to [&] { auto tmp = a; tmp += b; tmp += c; return tmp; }() removing a ton of temporary buffers (not objects, because CoW makes it impossible for the compiler to track the single conceptual object passing through the chain) when not using QStringBuilder (which isn't available for QList). This is BC, because the operators are all inline free functions or at least inline members of non-exported classes. Use multi-\fn to document the new operators. No \since is needed, as this doesn't change the set of supported operations, just makes some of them faster. [ChangeLog][QtCore][QList/QString/QByteArray] Chained additions (a + b + c) now produce only one temporary buffer for the whole expression instead of one per addition. Using += or QStringBuilder is still faster, though. Change-Id: I87e837d8803e79dc29c9268f73e6df9fcc0b09a3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* [docs] QList: fix history of clear() semantics changeMarc Mutz2022-11-271-10/+7
| | | | | | | | | | | | The description was copied from QVector, and doesn't exactly fit QList. For QList, the behavior changed in Qt 6.0 when QList became QVector, not in Qt 5.7, as indicated. Be more precise. Pick-to: 6.4 6.2 Change-Id: I4029d83128ec205f628125d78394e8ee79cc221f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Documentation: Fix information on how to iterate over listsFriedemann Kleint2022-11-241-15/+1
| | | | | | | | | | | | Remove the outdated code used for QStringList and point QStringList and QList to the containers page. Pick-to: 6.4 6.2 Task-number: QTBUG-108687 Change-Id: I6fae6410ca759f91da85832ddb9f24e8a0ce202b Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-26/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* corelib: Fix typos in documentationJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: I64d63af708bc6ddaabd12450eb3089e5077f849e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QList: more explicitly document capacity() shenanigansAndrei Golubev2021-06-171-3/+4
| | | | | | | | | | | Due to capacity() reporting the size of all allocated space, this is somewhat inconsistent with what QVector::capacity() in Qt5 provided, due to Q6List being double-ended. So let's document this better Task-number: QTBUG-92941 Pick-to: 6.2 Change-Id: Iba46389121e721a8d21f0344b154f41c2c245867 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-261-2/+2
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QList docs: lexicographical -> lexicalIvan Solovev2020-12-111-4/+4
| | | | | | | | | | | | | | | Lexicographical is not the right word for the comparison description. Other classes use the term "lexical", so QList is updated in that way too. The link to cppreference is left, because QList actually uses std::lexicographical_compare, so it's completely valid here. Pick-to: 6.0 Task-number: QTBUG-87962 Change-Id: I37bd3a92c5a3f857266e9c483d14e64eb90ce2c7 Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QList: update docsIvan Solovev2020-12-081-40/+48
| | | | | | | | | | | Update some wording to align with QString and QByteArray documentation Pick-to: 6.0 Task-number: QTBUG-87962 Change-Id: I8162769c1a5fc94fc8920ad0d4d91e95fe74825f Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* QList docs: extend prepend() descriptionIvan Solovev2020-12-021-5/+6
| | | | | | | | | | | | Current description was confronting the general description of the class, which states that prepend() is fast. The updated description gives more information about the method's behavior in different conditions. Pick-to: 6.0 Task-number: QTBUG-87962 Change-Id: I7b6dfb536d143d78c441214f83320c1bf1263e0d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Sequential general purpose containers: add erase/erase_ifGiuseppe D'Angelo2020-12-011-0/+35
| | | | | | | | | | | | | | | | | | | | This is refactor/revisit for Qt 6 of the original commit [1] by Marc, limited to QList and QVLA. [1] see 11aa9a2276ba5367adbbd96d0ba13111d58145f8 [ChangeLog][QtCore][QList] Added erase() and erase_if(), for consistent container erasure. Added removeIf() as a method, complementing removeOne() / removeAll(). [ChangeLog][QtCore][QVarLengthArray] Added erase() and erase_if(), for consistent container erasure. Added removeIf() as a method, complementing removeOne() / removeAll(). Change-Id: I2499504e221431ead754dd64cc8a4d4e9f116183 Done-by: Marc Mutz Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Doc: Fix various documentation warningsTopi Reinio2020-11-301-8/+6
| | | | | | | | | | | | | - QList iterators are now nested classes inside QList. - Drop reference to Qt OpenGL Widgets landing page, there is no such page. - Fix typos and linking issues. Fixes: QTBUG-86295 Pick-to: 6.0 Change-Id: I964843deb81aa55ff8ddb9a1c2b004cb72e68de9 Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Do not shrink on remove()Lars Knoll2020-11-091-15/+5
| | | | | | | | | | This is in line with Qt 5 behavior, how std::vector works and also how QString and QByteArray behave. If you need the shrink allocated storage, call squeeze() manually. Change-Id: I16cadd4f2a89bb2ec5de02fe69186f5da321cd06 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix qdoc issues in QListVolker Hilsheimer2020-10-301-2/+2
| | | | | | | | | Amends 3afd06cd43d78ef0992eaa6a458572eea6769297, member comparison operators are const. Change-Id: I10d1da4faabb6cfd528fc653ff138ab8878b32b6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Hide QList comparisons from ADLAllan Sandfeld Jensen2020-10-301-16/+12
| | | | | | | | | | Makes them member methods instead of hidden inline, as those actually gets listed in documentation, and two were already documented as such. Task-number: QTBUG-87975 Change-Id: I382ff8b701753f1fe150a38f4c530a52c98ad292 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Clean QList documentationAndrei Golubev2020-10-281-51/+60
| | | | | | | | | | | Updated QList documentation pieces: - Several descriptions revised - Irrelevant things removed - Descriptions wrapped at 80 characters Task-number: QTBUG-86553 Change-Id: Ic6de44520a76677aa5e8d9e91caa03e5aa198812 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QList: also default count()'s template parameterGiuseppe D'Angelo2020-10-261-1/+1
| | | | | | | | Also fix the docs. Change-Id: If08116cb8657d00d610de9451be0ba73ce19dcd1 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Update QList::append(const_reference) -> QList::append(parameter_type)Andrei Golubev2020-10-241-1/+1
| | | | | | | | | | Forgotten during previous round of replacing const lvalue references with parameter_type in QList methods Task-number: QTBUG-86553 Change-Id: I9abda4db3b504521b64fab1f220559c36bfeb9f5 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList/QVLA: fixup the docsGiuseppe D'Angelo2020-10-231-5/+5
| | | | | | | | | I'm not 100% sure that qdoc needs this, but in case it does, here's the commit. Change-Id: Ia3e17a56fd5df766c250f4875ba5e19e12b98d11 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QList: make (last)IndexOf and contains function templatesGiuseppe D'Angelo2020-10-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no reason why they shouldn't be; one might want to do a lookup passing an object which is comparable with the list's value type (e.g. search with a QByteArrayView needle into a QByteArrayList haystack). Insofar we've had to add overloads to QListSpecialMethods for all these cases, which clearly doesn't scale and creates top-tier and low-tier lists. There is one downside, namely, calling QList<A>::indexOf(B) for a B for which there isn't an operator==(A, B) but only a conversion towards A. Before, B was converted only once (at call site), now it's converted at every call of operator==. In general: such types are broken and should be fixed on their own. However let's avoid a possible regression in client code, so I've left the QString overloads in QStringList in. To get there: centralize the implementation of those methods in a empty base class, which gets then inherited by QListSpecialMethods, which is inherited by QList. This is there are still special methods that may want to overload contains, e.g. QStringList which also passes a case sensitivity). The only breakages comes from code that was already broken, for instance mixing signed and unsigned types, and the beauty of this is that now we *detect* that instead of silently ignoring. QVLA and other QList methods will be tackled in future commits. [ChangeLog][QtCore][QList] The indexOf, lastIndexOf and contains methods now take an object of any datatype -- and not just the list's own value type. This allows for heterogenous lookup in QLists. Change-Id: Ib34812217eb2b0f926fad1fc195b33758196941c Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use parameter_type in QList methodsAndrei Golubev2020-10-221-11/+11
| | | | | | | | | QList::parameter_type is defined and used to give better performance e.g. for arithmetic types. Let's use it consistently in QList API instead of const T & Change-Id: I2e12bd83f55679b55a14fbb23ab6172a9cf7bbcc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList docs: fix signature of removeAllGiuseppe D'Angelo2020-10-221-1/+1
| | | | | Change-Id: Ic52b6d9ab4b250dc931c650c6def35c18803ba43 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Convert QList alias definitions to 'using'Andrei Golubev2020-10-201-17/+9
| | | | | | | | | | | | Modern syntax for type aliases looks much nicer and is easier to read. Additionally, QDoc is able to generate better documentation for 'using' based aliases. Also, aliases are simplified for QDoc Task-number: QTBUG-86553 Change-Id: I44932fbd94f32c1463eafedd1b48c1e840b697e3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix QDoc warnings for QList/QVectorAndrei Golubev2020-10-201-17/+27
| | | | | | Task-number: QTBUG-86553 Change-Id: Iac944c78640bfcfb6ee137c0ef3dd89387700b4c Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* QList::removeOne: make it generic as wellGiuseppe D'Angelo2020-10-201-1/+1
| | | | | | Change-Id: I0c50b2ae76f9d0f053b3d5b1ab98d12e0524e419 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList docs: remove some QVector->QList leftoversGiuseppe D'Angelo2020-10-191-41/+5
| | | | | Change-Id: I2a7b5ef07ddb07a261110914088b9942801a3c25 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Update QList's documentation relevant to prepend optimizationAndrei Golubev2020-09-211-38/+65
| | | | | | Task-number: QTBUG-84320 Change-Id: I550f9dd7810855df0b0cc2bcbc78a97d6abaac7a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Update QList's documentation bitsAndrei Golubev2020-09-071-44/+43
| | | | | | | | Fixed some QList documentation that described old API/behavior Change-Id: I9101ebb7bed9bcac328509765f8e9b85d63d305b Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QList: Add a append(QList &&) overloadMårten Nordheim2020-08-011-0/+31
| | | | | | | | We already had append(const QList &) and now there's an overload taking an rvalue reference. Change-Id: Id2fbc6c57badebebeee7b80d15bb333270fa4e19 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Small fixes to the QList documentationLars Knoll2020-07-061-3/+3
| | | | | Change-Id: Ic839f7859912eb48bb192755d6f10536a0a73f8e Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
* Add support for first(n), last(n) and sliced() to QListLars Knoll2020-07-061-0/+49
| | | | | | | | | This keeps the API symmetric with what we have in our string classes. Change-Id: I94c5b39b718ca2472f9ca645e7a42e4314636f67 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Simplify Q_ARRAY_LITERALLars Knoll2020-07-061-5/+0
| | | | | | | And clean up some unused pieces of code. Change-Id: I285b6862dc67b7130af66d3e08f652b1a56b990e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use QList instead of QVector in corelib docsJarek Kobus2020-06-291-122/+120
| | | | | | | Task-number: QTBUG-84469 Task-number: QTBUG-85221 Change-Id: Ieb0ba7d82409e3c053a5788a01e92ea495505643 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Move implementation of QVector/List back to qlist.hLars Knoll2020-06-201-0/+1472
And name the main class QList. That's also the one we document. This gives less porting pain for our users, and a lot less churn in our API, as we use QList in Qt 5 in 95% of our API. In addition, it gives more consistent naming with QStringList and QByteArrayList and disambiguates QList vs QVector(2|3|4)D. Fixes: QTBUG-84468 Change-Id: I3cba9d1d3179969d8bf9320b31be2230d021d1a9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>