diff options
author | Kai Koehne <kai.koehne@qt.io> | 2020-05-07 18:21:32 +0200 |
---|---|---|
committer | Kai Koehne <kai.koehne@qt.io> | 2020-05-26 15:11:40 +0200 |
commit | 162ea888bf19fda2ccd28e58bf4688d96cf2b6af (patch) | |
tree | dc109e7a7d3a0becd8aac865b06df4af27734def /src/corelib/doc/src/qt6-changes.qdoc | |
parent | b22910043087f1909bd9219953e0af869430dc39 (diff) |
Doc: Document Qt 6 changes for QHash, QMultiHash, QSet
Change-Id: I9a83d33f05d7c3e5d23399129dfac45a1cb0d6ad
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/doc/src/qt6-changes.qdoc')
-rw-r--r-- | src/corelib/doc/src/qt6-changes.qdoc | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/corelib/doc/src/qt6-changes.qdoc b/src/corelib/doc/src/qt6-changes.qdoc index 2802ab12cd..21bbd499ed 100644 --- a/src/corelib/doc/src/qt6-changes.qdoc +++ b/src/corelib/doc/src/qt6-changes.qdoc @@ -38,4 +38,51 @@ In this topic we summarize those changes in Qt Core, and provide guidance to handle them. + + \section1 Container Classes + + \section2 QHash, QMultiHash, QSet + + \section3 qHash() Signature + + For custom types, QHash and QMultiHash rely on you providing + a \l{The qHash() hashing function} {custom qHash() function} + in the same namespace. In Qt 4 and Qt 5, the return + value and optional second argument of a \c qHash function + was of type \c uint. In Qt 6, it is \c size_t. + + That is, you need to change + + \code + uint qHash(MyType x, uint seed); + \endcode + + to + + \code + size_t qHash(MyType x, size_t seed); + \endcode + + This allows QHash, QMultiHash and QSet to hold more than 2^32 items on + 64 bit platforms. + + \section3 Stability of References + + The implementation of QHash and QMultiHash in Qt 6 got changed from + a node based approach to a two stage lookup table. This design allows + to keep the memory overhead of a hash instance very small, while + at the same time giving good performance. + + One behavioral change to note is that the new QHash implementation + will not provide stable references to elements in the hash when the + table needs to grow, or when entries are removed. Applications that + rely on such stability might now run into undefined behavior. + + \section3 Removal of QHash::insertMulti + + In Qt 5, QHash could be used to create multi-valued hashes by using + QHash::insertMulti, and QMultiHash was deriving vom QHash. + + In Qt 6, both types and use cases are distinct, and QHash::insertMulti + got removed. */ |