diff options
Diffstat (limited to 'src/corelib/tools/qhash.cpp')
-rw-r--r-- | src/corelib/tools/qhash.cpp | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index b334a697a9..7520158293 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -682,17 +682,17 @@ void QHashData::dump() void QHashData::checkSanity() { - if (fakeNext) + if (Q_UNLIKELY(fakeNext)) qFatal("Fake next isn't 0"); for (int i = 0; i < numBuckets; ++i) { Node *n = buckets[i]; Node *p = n; - if (!n) + if (Q_UNLIKELY(!n)) qFatal("%d: Bucket entry is 0", i); if (n != reinterpret_cast<Node *>(this)) { while (n != reinterpret_cast<Node *>(this)) { - if (!n->next) + if (Q_UNLIKELY(!n->next)) qFatal("%d: Next of %p is 0, should be %p", i, n, this); n = n->next; } @@ -711,6 +711,23 @@ void QHashData::checkSanity() Types \c T1 and \c T2 must be supported by qHash(). */ +/*! + \fn uint qHash(const std::pair<T1, T2> &key, uint seed = 0) + \since 5.7 + \relates QHash + + Returns the hash value for the \a key, using \a seed to seed the calculation. + + Types \c T1 and \c T2 must be supported by qHash(). + + \note The return type of this function is \e{not} the same as that of + \code + qHash(qMakePair(key.first, key.second), seed); + \endcode + The two functions use different hashing algorithms; due to binary compatibility + constraints, we cannot change the QPair algorithm to match the std::pair one before Qt 6. +*/ + /*! \fn uint qHashRange(InputIterator first, InputIterator last, uint seed = 0) \relates QHash \since 5.5 @@ -1632,7 +1649,8 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW \sa keyBegin() */ -/*! \fn QHash::iterator QHash::erase(iterator pos) +/*! \fn QHash::iterator QHash::erase(const_iterator pos) + \since 5.7 Removes the (key, value) pair associated with the iterator \a pos from the hash, and returns an iterator to the next item in the @@ -1648,6 +1666,10 @@ uint qHash(long double key, uint seed) Q_DECL_NOTHROW \sa remove(), take(), find() */ +/*! \fn QHash::iterator QHash::erase(iterator pos) + \overload +*/ + /*! \fn QHash::iterator QHash::find(const Key &key) Returns an iterator pointing to the item with the \a key in the |