From c6cdf38e752c22babdbe645366bdfb7ce51d01ff Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 31 Jan 2020 12:11:54 +0100 Subject: Change qHash() to work with size_t instead of uint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required, so that QHash and QSet can hold more than 2^32 items on 64 bit platforms. The actual hashing functions for strings are still 32bit, this will be changed in a follow-up commit. Change-Id: I4372125252486075ff3a0b45ecfa818359fe103b Reviewed-by: MÃ¥rten Nordheim --- .../doc/snippets/code/src_corelib_tools_qhash.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/corelib/doc/snippets') diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp index d30ad50ffc..1f2c505a02 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp @@ -149,7 +149,7 @@ inline bool operator==(const Employee &e1, const Employee &e2) && e1.dateOfBirth() == e2.dateOfBirth(); } -inline uint qHash(const Employee &key, uint seed) +inline size_t qHash(const Employee &key, size_t seed) { return qHash(key.name(), seed) ^ key.dateOfBirth().day(); } @@ -312,7 +312,7 @@ qDeleteAll(hash2.keyBegin(), hash2.keyEnd()); //! [28] //! [qhashbits] -inline uint qHash(const std::vector &key, uint seed = 0) +inline size_t qHash(const std::vector &key, size_t seed = 0) { if (key.empty()) return seed; @@ -322,14 +322,14 @@ inline uint qHash(const std::vector &key, uint seed = 0) //! [qhashbits] //! [qhashrange] -inline uint qHash(const std::vector &key, uint seed = 0) +inline size_t qHash(const std::vector &key, size_t seed = 0) { return qHashRange(key.begin(), key.end(), seed); } //! [qhashrange] //! [qhashrangecommutative] -inline uint qHash(const std::unordered_set &key, uint seed = 0) +inline size_t qHash(const std::unordered_set &key, size_t seed = 0) { return qHashRangeCommutative(key.begin(), key.end(), seed); } @@ -348,9 +348,9 @@ qHash(qMakePair(key.first, key.second), seed); //! [31] //! [32] -uint qHash(K key); -uint qHash(const K &key); +size_t qHash(K key); +size_t qHash(const K &key); -uint qHash(K key, uint seed); -uint qHash(const K &key, uint seed); +size_t qHash(K key, size_t seed); +size_t qHash(const K &key, size_t seed); //! [32] -- cgit v1.2.3