From 312b414d8f2d82d3a8e360fc5419b36700121f8b Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Fri, 22 Jan 2016 10:48:14 +0100 Subject: [PATCH] Adapts XORFastHashStorage to XORFastHash compile time limits --- include/util/xor_fast_hash_storage.hpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/include/util/xor_fast_hash_storage.hpp b/include/util/xor_fast_hash_storage.hpp index 297aabb2f..6d2d76baa 100644 --- a/include/util/xor_fast_hash_storage.hpp +++ b/include/util/xor_fast_hash_storage.hpp @@ -11,7 +11,8 @@ namespace osrm namespace util { -template class XORFastHashStorage +template +class XORFastHashStorage { public: struct HashCell @@ -26,22 +27,18 @@ template class XORFastHashStorage } HashCell(const HashCell &other) : time(other.key), id(other.id), key(other.time) {} - operator Key() const { return key; } - void operator=(const Key key_to_insert) { key = key_to_insert; } }; - XORFastHashStorage() = delete; - - explicit XORFastHashStorage(size_t) : positions(1u << 16u), current_timestamp(0) {} + explicit XORFastHashStorage(size_t) : positions(MaxNumElements), current_timestamp{0u} {} HashCell &operator[](const NodeID node) { std::uint16_t position = fast_hasher(node); while ((positions[position].time == current_timestamp) && (positions[position].id != node)) { - ++position %= (1u << 16u); + ++position %= MaxNumElements; } positions[position].time = current_timestamp; @@ -58,7 +55,7 @@ template class XORFastHashStorage std::uint16_t position = fast_hasher(node); while ((positions[position].time == current_timestamp) && (positions[position].id != node)) { - ++position %= (1u << 16u); + ++position %= MaxNumElements; } BOOST_ASSERT(position < positions.size()); @@ -72,13 +69,13 @@ template class XORFastHashStorage if (std::numeric_limits::max() == current_timestamp) { positions.clear(); - positions.resize(1u << 16u); + positions.resize(MaxNumElements); } } private: std::vector positions; - XORFastHash<> fast_hasher; + XORFastHash fast_hasher; unsigned current_timestamp; }; }