From 58ec01e278496bdaaee05546beb543a119de4277 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 2 Jul 2012 09:01:56 +0100 Subject: More qHash(T, uint) support Add the seed to QPair, QUuid, QPersistentModelIndex's qHash(), and fix qHash documentation for them and for many other datatypes. Change-Id: I1386f3ed42ee1a832371a242ee5c82895ba92c2b Reviewed-by: Thiago Macieira --- src/corelib/plugin/quuid.cpp | 15 +++++++++------ src/corelib/plugin/quuid.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/corelib/plugin') diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp index bfe8dfc3c4..952e41851a 100644 --- a/src/corelib/plugin/quuid.cpp +++ b/src/corelib/plugin/quuid.cpp @@ -999,14 +999,17 @@ QDebug operator<<(QDebug dbg, const QUuid &id) } #endif -/** - Returns a hash of the QUuid - */ -uint qHash(const QUuid &uuid) +/*! + \since 5.0 + \relates QUuid + Returns a hash of the UUID \a uuid, using \a seed to seed the calculation. +*/ +uint qHash(const QUuid &uuid, uint seed) { return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) - ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) - ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]); + ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) + ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) + ^ seed; } diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h index e595613e8f..7fd32a307b 100644 --- a/src/corelib/plugin/quuid.h +++ b/src/corelib/plugin/quuid.h @@ -227,7 +227,7 @@ Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QUuid &); Q_CORE_EXPORT QDebug operator<<(QDebug, const QUuid &); #endif -Q_CORE_EXPORT uint qHash(const QUuid &uuid); +Q_CORE_EXPORT uint qHash(const QUuid &uuid, uint seed = 0); QT_END_NAMESPACE -- cgit v1.2.3