summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlist.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove MSVC workaround for QPolygonMarcel Krems2020-08-291-66/+0
| | | | | Change-Id: I62f7c6da7629dcdfda653a136d3bcd483359c86c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Move implementation of QVector/List back to qlist.hLars Knoll2020-06-201-4/+4
| | | | | | | | | | | | | 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>
* Make QList an alias to QVectorLars Knoll2019-10-301-2025/+0
| | | | | | | | | | | | | This is almost 100% source compatible with Qt 5. Exceptions are * Stability of references for large or non movable types * taking a PMF for types that are now overloaded with r-value references in QVector * The missing prepend optimization in QVector (that is still planned to come for Qt 6) Change-Id: I96d44553304dd623def9c70d6fea8fa2fb0373b0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-261-0/+12
|\ | | | | | | Change-Id: I208a36bf1c88c8291baaa5ca8fe8e838bc9d7aea
| * QSet: Document to/from QVector transformation techniquesSamuel Gaist2019-10-241-0/+12
| | | | | | | | | | | | | | Change-Id: I2a2ff6332bd6e8ed3d4ba7b4765da0a94a06f133 Fixes: QTBUG-71067 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | Deprecate calling QList::insert/removeAt with out of bounds indexLars Knoll2019-10-101-3/+4
|/ | | | | | | | | | | | | | Users should not call any QList API with indices that are out of bounds. Deprecate this behavior and make sure users get warnings in debug mode and assertions if they disable deprecated functionality. [ChangeLog][Important Behavior Changes] Calling QList::insert() or removeAt() with an out of bounds index is deprecated and will not be supported in Qt 6 anymore. Change-Id: I97adecc2e2aabd36ea2cc69e0895d625f78b32a0 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
* Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-1/+1
| | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Non-associative containers: add range constructorsMarc Mutz2019-04-171-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Something nice we'd like to detect for array-backed containers is if the iterator passed is a Contiguous one; if the type is also trivially copyable / Q_PRIMITIVE_TYPE, we could memcpy() the whole range. However, there's no trait in the Standard to detect contiguous iterators (the best approximation would be detecting if the iterator is actually a pointer). Also, it's probably not smart to do the work now for QVector since QVector needs refactoring anyhow, and this work will be lost. QString and QByteArray are left in another commit. [ChangeLog][QtCore][QVector] Added range constructor. [ChangeLog][QtCore][QVarLengthArray] Added range constructor. [ChangeLog][QtCore][QList] Added range constructor. [ChangeLog][QtCore][QStringList] Added range constructor. [ChangeLog][QtCore][QLinkedList] Added range constructor. [ChangeLog][QtCore][QSet] Added range constructor. Change-Id: I220edb796053c9c4d31a6dbdc7efc5fc0f6678f9 Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
* Add missing \since to QList<T>::swapItemsAt()Friedemann Kleint2019-02-121-0/+1
| | | | | | | Amends 7f4d0405b409b1d3aa9d91e31972669576ec698c. Change-Id: I4de38428ea4a0e448e2930d19d94821884f7331e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Rename QList<T>::swap(int, int) to swapItemsAt()Lars Knoll2018-12-031-0/+7
| | | | | | | | | | | The old name was confusing as it conflicted with QList<T>::swap(QList &other), that was doing something completely different. Rename the method to swapItemsAt() which is a lot clearer. Change-Id: Iac77a1e790a7256766f83a24d2a243c880d875f4 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* Invert include dependencies between QList and QVectorLars Knoll2018-12-031-0/+17
| | | | | | | | | | | | This is a very slight source incompatibility, but required as a preparation for Qt 6, where QList should inherit QVector or share the implementation with it. This requires some special work to correctly instantiate and export QVector<QPoint> from Qt Core on MSVC. Change-Id: I1d042c5fafdde7afe59409eda2580871d4832fcd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Advocate use of std::initializer_list constructor in Q[String]ListKai Koehne2018-04-231-4/+9
| | | | | | | | | We're relying on C++11 since a while, so lets not advertise creating lists of strings with operator<<() anymore. Change-Id: I14a3442ff852ac2c106d90c63504eb9ebb737609 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: hjk <hjk@qt.io>
* doc: Add missing return types to \fn commands, fix mis-specified onesMartin Smith2018-01-181-1/+1
| | | | | | | | | | | This update corrects several qdoc warnings about undocumented parameters, which are actually caused when the return type is not included in the \fn command, or when the return type is mis-specified (includes static, or lacks needed template parameters). Change-Id: Ic49139b88424e93609fbd01bc0836436d13a8f9a Reviewed-by: Topi Reiniö <topi.reinio@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add template text to \fn commands in container classesMartin Smith2017-12-011-147/+147
| | | | | | | | | | The \fn commands were not recognized by clang-qdoc because the template stuff was missing from the \fn commands. This update adds the correct template text and parameters. It eliminates nearly 2000 qdoc warnings. Change-Id: Ibe047424396a8f99f8bd64efea1b0d8cc7c7527d Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-051-1/+1
|\ | | | | | | Change-Id: I34b5e290233d0869fbafac094a939aec2bf83fd5
| * Fix some typos and minor sentence structure issues in docsFrederik Schwarzer2016-10-051-1/+1
| | | | | | | | | | Change-Id: Ibede1aeb046e2df6723e3041152bfae22a9fde32 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Replace qAllocMore with a pair of more useful functionsThiago Macieira2016-06-091-19/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The first is "exact", not "more": qCalculateBlockSize. It ensures that there's no overflow in multiplying, adding the header size or when converting back to an int. The second is the replacement for qAllocMore: it calculates the block size like the first, but increases the block size to accommodate future appends. The number of elements that fit in the block is also returned. Task-number: QTBUG-41230 Change-Id: I52dd43c12685407bb9a6ffff13f5da09f816e667 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Updated license headersJani Heikkinen2016-01-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | From Qt 5.7 -> tools & applications are lisenced under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) Change-Id: I42a473ddc97101492a60b9287d90979d9eb35ae1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-14/+20
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Doc: improvement in if condition about inserting item in listNico Vertriest2015-11-301-2/+2
| | | | | | Task-number: QTBUG-41708 Change-Id: Ibbb115a8ad81f7fba0ce162ae131d4843b19c188 Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
* qdoc: Allow formal parameters in link targetsMartin Smith2015-08-161-1/+1
| | | | | | | | | | | | | | This update allows qdoc to handle \l commands for linking to functions, where the formal parameters are included in the link target. For example, \l {QWidget::find(QString name)} will only match a member function of QWidget that has a single parameter of type QString. The parameter name is not used in the search. Change-Id: I8a31c9a7ed632f12a0e6d8a33cbb5cd361098317 Task-number: QTBUG-47286 Reviewed-by: Martin Smith <martin.smith@digia.com>
* Add a dedicated QListData::realloc_grow for growing QListThiago Macieira2015-08-101-3/+15
| | | | | | | | | This hides the call to ::grow to now two places in the source code, so it will be easier to fix the inefficient call to qAllocMore. Change-Id: I5d1e6f7607404caa96e4ffff13e80a3e4cb0ee93 Reviewed-by: Ulf Hermann <ulf.hermann@theqtcompany.com> Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com>
* doc: Corrected docs for QList and QVectorMartin Smith2015-07-271-50/+74
| | | | | | | | | | | | The docs for QList advised users to choose QList over QVector for efficiency reasons. The advise should be to use QVector over QList for efficiency reasons. This update corrects that misunderstanding. Change-Id: Ie04c99ab7fe6aef4bd1d39175c9564455b0122de Task-number: QTBUG-47196 Reviewed-by: Topi Reiniö <topi.reinio@digia.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* QList: Introduce constFirst() and constEnd()Sérgio Martins2015-06-271-2/+22
| | | | | | | | | | Allows to easily prevent detaching in common code like: getList().first() [ChangeLog][QtCore][QList] Added the convenience constFirst and constLast functions. Task-number: QTBUG-46026 Change-Id: I51ecb51fe91fc7d993ad35b5c7392f4da88e5f7b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add qHash(QList)Marc Mutz2015-04-201-0/+11
| | | | | | | | | QLists can be compared for equality, so qHash should be overloaded, too. [ChangeLog][QtCore][QList] Added qHash(QList). Change-Id: I9ad91811f12479764cc17d87192539612ceb0b4c Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QList: add {const_,reverse_iterator}, {c,}r{begin,end}()Marc Mutz2015-04-051-0/+78
| | | | | | | | | [ChangeLog][QtCore][QList] Added rbegin(), crbegin(), rend(), crend(), and reverse_iterator and const_reverse_iterator typedefs. Task-number: QTBUG-25919 Change-Id: Icce870c22931e68cdcedd1519651bfa374ac44af Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList: add relational operators <,<=,>,>=Marc Mutz2015-04-051-0/+48
| | | | | | | | | | std::vector has them, too. [ChangeLog][QtCore][QList] Added relational operators <, <=, >, >= if the element type supports operator<. Change-Id: Id2bd905e92c0365ad9f439d49908045c8df309c3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Move a few QStringList methods up to QList<QString>Thiago Macieira2015-01-071-0/+6
| | | | | | | | This should be completely source-compatible, aside from the indirect header order change. Change-Id: I4cf8800ea1bfeb3023c7319991ab8ae281c925e8 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-11-241-10/+10
|\ | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice.cpp src/plugins/bearer/linux_common/qofonoservice_linux.cpp src/plugins/bearer/linux_common/qofonoservice_linux_p.h src/plugins/platforms/android/qandroidplatformtheme.cpp src/tools/bootstrap/bootstrap.pro src/widgets/styles/qmacstyle_mac.mm Change-Id: Ia02aab6c4598ce74e9c30bb4666d5e2ef000f99b
| * Fix warnings about size conversion in QListThiago Macieira2014-10-311-10/+10
| | | | | | | | | | | | | | | | | | | | | | Because difference_type is 64-bit on 64-bit systems, there's a downconversion warning from MSVC and possibly other compilers when it gets passed to functions taking simply int. Task-number: QTBUG-41092 Change-Id: I46a710810f4a57b8b84c4933f419a1f1fdf6bb5a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Check for integer overflows in places where qAllocMore is usedUlf Hermann2014-10-171-0/+2
|/ | | | | | | Task-number: QTBUG-41230 Change-Id: I5e932c2540c0bd67f13fab3ae20975d459f82c08 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Doc: Use title case in section1 titlesNico Vertriest2014-09-301-1/+1
| | | | | | | | Using Python script title-cased.py Task-number: QTBUG-41250 Change-Id: I00d3d7a0b30db7304a7904efd6d63abd9a7b493b Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Doc: corrected autolink errors qtbase/corelib/toolsNico Vertriest2014-09-241-2/+2
| | | | | | | | | Also corrected some minor language/spelling issues Task-number: QTBUG-40362 Change-Id: I00d76521fc9beb4e7a4a83ff6dc3334a055a7148 Reviewed-by: Topi Reiniö <topi.reinio@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Move the special QByteArrayList methods into QListThiago Macieira2014-08-091-0/+5
| | | | | | | | | | | | | | | | | | | | | | | and make QByteArrayList be a simple typedef. As a side-effect, the constructor taking a QByteArray is no longer available since I couldn't find a way to add it to QList<T> when T is QByteArray. My template-foo failed me. I tried: - QEnableIf<is_same<T, QByteArray>::value, QByteArray>::type => makes QList fail to compile for any T that isn't QByteArray - make the constructor a template member => it compiles if the parameter is a QByteArray, but not a const char[4] like the test was - inheriting constructors => runs into ICC and Clang bugs that I could not work around Besides, the constructor with std::initializer_list is a superior solution anyway. Change-Id: Ic86fbadc1104142bfd907a5c4147199bf839fb89 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Unify all mid() functions in QtBase.Jędrzej Nowacki2014-05-161-3/+3
| | | | | | | | | | | | | | | | | | | Up to now, Qt had at least 3 different implementations of the mid(). Only QString::mid implementation was not crashing on edge cases and was protected against overflows, therefore I picked that one as the base implementation, even if it has weird semantics for an invalid input. As a side effect QVector::mid was slightly optimized to not detach in all cases (which follows current QList behavior). Documentation of QVector::mid and QList::mid was updated to not mention "copy of data" which could suggest that the mid() result is detached. QStringRef::mid was fixed and now it follows general Qt behavior, by returning a null value for a null input. Change-Id: Ie9ff5d98372bd193d66508e6dd92b6ed1180ad9b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve implicit shared documentation a bitThorbjørn Martsum2013-10-151-0/+10
| | | | | | | | Task-number: QTBUG-27061 Change-Id: I66e000a9f59fda3654066013e6e78c3ba6fd27fe Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList - fix a few doc issuesThorbjørn Martsum2013-10-151-10/+14
| | | | | | | | | Though some of it was mensioned in the introduction to the class, we are not in O(1) if we modify a shared container. Change-Id: If63b4cb4bdfc98d6b1333bae307e5650341e5484 Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-28/+28
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Doc: Add docs for rvalue references and move constructorsGeir Vattekar2013-09-271-0/+17
| | | | | | | | | These members were introduced in 4.8, but left undocumented. Because we consider undocumented API to be internal, the members are \since 5.2. Change-Id: I52e2840a8cfaa7f59f410b3e2a06c0942ea06539 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* Update the documentation for C++11 initializer lists supportLaszlo Papp2013-03-071-1/+2
| | | | | | | | The documentation was written for 4.8 when the C++11 standard did not have the name yet. Change-Id: I08640a5ae62385b09e181eefafd4cc831e4de456 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QtBase: Doc: Fix links to STL-style iteratorsDavid Schulz2012-12-061-6/+6
| | | | | Change-Id: I2822c2a7e9bfc1949c20ff81e08961f641e961fb Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Remove qSort from QList/QSet docsGiuseppe D'Angelo2012-11-161-1/+1
| | | | | Change-Id: I82ac7cafbda3bb6d54a0ba26903ab11113640067 Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-231-0/+3
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Remove use of ::free from qlist.hThiago Macieira2012-08-091-0/+6
| | | | | | | | | | | | | | | | | The memory is allocated in qlist.cpp, so it should be freed in qlist.cpp. Freeing it in qlist.cpp ties our hands about future improvements to the allocator. In addition, silence the warning by the too-smart-for-its-own-good GCC that we're trying to free a non-heap object: qlist.h:763:14: warning: attempt to free a non-heap object "QListData::shared_null" [-Wfree-nonheap-object] The warning is wrong. It should say "possibly" somewhere because GCC failed to account for all conditions in the path to free(). Change-Id: I34a6c16bba9a2197fc83eb3c7a63ae06fb25bf15 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
* QtCore: remove \link usagesGiuseppe D'Angelo2012-05-291-2/+2
| | | | | Change-Id: I0de764b51a972de0b6eb2bf3c04d2b190f581f52 Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Doc: Prepare for building modular QtCore docs.Casper van Donderen2012-04-191-29/+29
| | | | | | | | | | | | This change fixes most qdoc errors in QtCore. There are about 900 left. The main thing this change does is moving documentation from qtcore from /doc/src to /src/corelib/doc. Other issues resolved are mis-use of qdoc commands. Change-Id: I002d01edfb13575e8bf27ce91596a577a92562d1 Reviewed-by: Lars Knoll <lars.knoll@nokia.com> Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com> Reviewed-by: Jerome Pasion <jerome.pasion@nokia.com>