diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/corelib/tools/qhash.cpp | 32 | ||||
| -rw-r--r-- | src/corelib/tools/qhash.h | 5 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 18d1cee0ebd..5320ea1fbf7 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -737,6 +737,38 @@ void QHashData::checkSanity() Returns the hash value for the \a key, using \a seed to seed the calculation. */ +/*! \relates QHash + \since 5.3 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ +uint qHash(float key, uint seed) Q_DECL_NOTHROW +{ + return key != 0.0f ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ; +} + +/*! \relates QHash + \since 5.3 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ +uint qHash(double key, uint seed) Q_DECL_NOTHROW +{ + return key != 0.0 ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ; +} + +#ifndef Q_OS_DARWIN +/*! \relates QHash + \since 5.3 + + Returns the hash value for the \a key, using \a seed to seed the calculation. +*/ +uint qHash(long double key, uint seed) Q_DECL_NOTHROW +{ + return key != 0.0L ? hash(reinterpret_cast<const uchar *>(&key), sizeof(key), seed) : seed ; +} +#endif + /*! \fn uint qHash(QChar key, uint seed = 0) \relates QHash \since 5.0 diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h index 9dd0e6144de..d4bf8df4428 100644 --- a/src/corelib/tools/qhash.h +++ b/src/corelib/tools/qhash.h @@ -85,6 +85,11 @@ inline uint qHash(quint64 key, uint seed = 0) Q_DECL_NOTHROW } } inline uint qHash(qint64 key, uint seed = 0) Q_DECL_NOTHROW { return qHash(quint64(key), seed); } +Q_CORE_EXPORT uint qHash(float key, uint seed = 0) Q_DECL_NOTHROW; +Q_CORE_EXPORT uint qHash(double key, uint seed = 0) Q_DECL_NOTHROW; +#ifndef Q_OS_DARWIN +Q_CORE_EXPORT uint qHash(long double key, uint seed = 0) Q_DECL_NOTHROW; +#endif inline uint qHash(QChar key, uint seed = 0) Q_DECL_NOTHROW { return qHash(key.unicode(), seed); } Q_CORE_EXPORT uint qHash(const QByteArray &key, uint seed = 0) Q_DECL_NOTHROW; Q_CORE_EXPORT uint qHash(const QString &key, uint seed = 0) Q_DECL_NOTHROW; |
