diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-08-14 11:22:23 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-01-18 19:36:06 +0100 |
commit | b8e46fce5c70c399c615e1b846076f379db173c5 (patch) | |
tree | d91cca50e2039845328e25c2ddf8188ea122d0f7 /src/corelib | |
parent | 70e3935c38c077e35629a6651479a8a9f9e9f528 (diff) |
Add qHash() overload for QSet
...using qHashRangeCommutative(). Also add a test.
[ChangeLog][QtCore][QSet] Can now be used as the key in QSet, QHash.
Change-Id: Ie7c81d257a3b324fc03d394fa7c9fcf0c6fb062a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/tools/qset.h | 9 | ||||
-rw-r--r-- | src/corelib/tools/qset.qdoc | 11 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h index 662afbf84a..baa412a550 100644 --- a/src/corelib/tools/qset.h +++ b/src/corelib/tools/qset.h @@ -237,6 +237,15 @@ private: } }; +template <typename T> +uint qHash(const QSet<T> &key, uint seed = 0) +Q_DECL_NOEXCEPT_EXPR(noexcept(qHashRangeCommutative(key.begin(), key.end(), seed))) +{ + return qHashRangeCommutative(key.begin(), key.end(), seed); +} + +// inline function implementations + template <class T> Q_INLINE_TEMPLATE void QSet<T>::reserve(int asize) { q_hash.reserve(asize); } diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc index ab7d72611e..73599a2a72 100644 --- a/src/corelib/tools/qset.qdoc +++ b/src/corelib/tools/qset.qdoc @@ -968,3 +968,14 @@ \sa{Serializing Qt Data Types}{Format of the QDataStream operators} */ + +/*! + \fn uint qHash(const QSet<T> &key, uint seed = 0) + \relates QHash + \since 5.5 + + Returns the hash value for the \a key, using \a seed to seed the calculation. + + The hash value is independent of the order of elements in \a key, that is, sets + that contain the same elements hash to the same value. +*/ |