summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/location/maps/qgeotilespec.cpp12
-rw-r--r--src/location/maps/qgeotilespec_p.h4
-rw-r--r--src/location/maps/qgeotilespec_p_p.h13
3 files changed, 19 insertions, 10 deletions
diff --git a/src/location/maps/qgeotilespec.cpp b/src/location/maps/qgeotilespec.cpp
index 8249101a..ad68a7d4 100644
--- a/src/location/maps/qgeotilespec.cpp
+++ b/src/location/maps/qgeotilespec.cpp
@@ -99,15 +99,9 @@ bool QGeoTileSpec::isLess(const QGeoTileSpec &rhs) const noexcept
return (*(d.constData()) < *(rhs.d.constData()));
}
-unsigned int qHash(const QGeoTileSpec &spec)
-{
- unsigned int result = (qHash(spec.plugin()) * 13) % 31;
- result += ((spec.mapId() * 17) % 31) << 5;
- result += ((spec.zoom() * 19) % 31) << 10;
- result += ((spec.x() * 23) % 31) << 15;
- result += ((spec.y() * 29) % 31) << 20;
- result += (spec.version() % 3) << 25;
- return result;
+size_t QGeoTileSpec::hash(size_t seed) const noexcept
+{
+ return d->hash(seed);
}
QDebug operator<< (QDebug dbg, const QGeoTileSpec &spec)
diff --git a/src/location/maps/qgeotilespec_p.h b/src/location/maps/qgeotilespec_p.h
index 91b5d76c..27365f1c 100644
--- a/src/location/maps/qgeotilespec_p.h
+++ b/src/location/maps/qgeotilespec_p.h
@@ -72,9 +72,11 @@ private:
bool isEqual(const QGeoTileSpec &rhs) const noexcept;
bool isLess(const QGeoTileSpec &rhs) const noexcept;
+ size_t hash(size_t seed) const noexcept;
+ friend size_t qHash(const QGeoTileSpec &key, size_t seed = 0) noexcept
+ { return key.hash(seed); }
};
-Q_LOCATION_EXPORT unsigned int qHash(const QGeoTileSpec &spec);
Q_LOCATION_EXPORT QDebug operator<<(QDebug, const QGeoTileSpec &);
diff --git a/src/location/maps/qgeotilespec_p_p.h b/src/location/maps/qgeotilespec_p_p.h
index 0f1c2314..cf07b1f7 100644
--- a/src/location/maps/qgeotilespec_p_p.h
+++ b/src/location/maps/qgeotilespec_p_p.h
@@ -15,6 +15,7 @@
// We mean it.
//
+#include <QtCore/qhashfunctions.h>
#include <QString>
#include <QSharedData>
@@ -29,6 +30,18 @@ public:
x_(x), y_(y), version_(version)
{}
+
+ size_t hash(size_t seed) const
+ {
+ return qHashMulti(seed,
+ mapId_,
+ zoom_,
+ x_,
+ y_,
+ version_,
+ plugin_);
+ }
+
inline bool operator==(const QGeoTileSpecPrivate &rhs) const
{
return mapId_ == rhs.mapId_