diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-23 15:22:28 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-23 15:52:41 +0200 |
commit | 7eb070b4504e9a3cfac8aee582e84105cd8ebe04 (patch) | |
tree | acd15a9f08d555c677e33f5695ac5de3a20ec783 /src | |
parent | 5e86aa93fc61ab6eb48b2da1704cd7ced6bc302d (diff) |
QVarLengthArray: add qHash overload
[ChangeLog][QtCore][QVarLengthArray] Added a qHash overload.
Change-Id: I771203ae3bb575b49f70e9114287dd2690031b42
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qvarlengtharray.h | 8 | ||||
-rw-r--r-- | src/corelib/tools/qvarlengtharray.qdoc | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h index 01fc63b677..a49e0af687 100644 --- a/src/corelib/tools/qvarlengtharray.h +++ b/src/corelib/tools/qvarlengtharray.h @@ -44,6 +44,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qalgorithms.h> #include <QtCore/qcontainertools_impl.h> +#include <QtCore/qhashfunctions.h> #include <algorithm> #include <initializer_list> @@ -599,6 +600,13 @@ inline bool operator>=(const QVarLengthArray<T, Prealloc1> &lhs, const QVarLengt return !(lhs < rhs); } +template <typename T, int Prealloc> +uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) + noexcept(noexcept(qHashRange(key.cbegin(), key.cend(), seed))) +{ + return qHashRange(key.cbegin(), key.cend(), seed); +} + QT_END_NAMESPACE #endif // QVARLENGTHARRAY_H diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc index 80769e3769..e5ba47b8ef 100644 --- a/src/corelib/tools/qvarlengtharray.qdoc +++ b/src/corelib/tools/qvarlengtharray.qdoc @@ -903,3 +903,11 @@ \sa indexOf(), lastIndexOf() */ +/*! + template <typename T, int Prealloc> uint qHash(const QVarLengthArray<T, Prealloc> &key, uint seed = 0) + \relates QVarLengthArray + \since 5.14 + + Returns the hash value for \a key, using \a seed to seed the + calculation. +*/ |