summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-01-31 12:11:54 +0100
committerLars Knoll <lars.knoll@qt.io>2020-04-09 20:03:25 +0200
commitc6cdf38e752c22babdbe645366bdfb7ce51d01ff (patch)
tree450b02523cb5a16791674ad1d06fb68c72eac971 /src/corelib/doc/snippets
parent775945137b6ef62de9a7d416b1fe59d79006ba82 (diff)
Change qHash() to work with size_t instead of uint
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 <marten.nordheim@qt.io>
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qhash.cpp16
1 files changed, 8 insertions, 8 deletions
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<int> &key, uint seed = 0)
+inline size_t qHash(const std::vector<int> &key, size_t seed = 0)
{
if (key.empty())
return seed;
@@ -322,14 +322,14 @@ inline uint qHash(const std::vector<int> &key, uint seed = 0)
//! [qhashbits]
//! [qhashrange]
-inline uint qHash(const std::vector<int> &key, uint seed = 0)
+inline size_t qHash(const std::vector<int> &key, size_t seed = 0)
{
return qHashRange(key.begin(), key.end(), seed);
}
//! [qhashrange]
//! [qhashrangecommutative]
-inline uint qHash(const std::unordered_set<int> &key, uint seed = 0)
+inline size_t qHash(const std::unordered_set<int> &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]