diff --git a/include/rexy/cx/hash.hpp b/include/rexy/cx/hash.hpp index bc9b7c5..4d735d7 100644 --- a/include/rexy/cx/hash.hpp +++ b/include/rexy/cx/hash.hpp @@ -25,7 +25,7 @@ namespace rexy::cx{ template struct hash{ - constexpr size_t operator()(const T& t, size_t salt = 0)const noexcept{ + constexpr size_t operator()(const T& t, size_t salt)const noexcept{ constexpr size_t bytes = sizeof(size_t); size_t val = static_cast(t); size_t hash = 5381 + salt; //magic hash number diff --git a/include/rexy/cx/hashmap.hpp b/include/rexy/cx/hashmap.hpp index 7f2e971..01dd2ae 100644 --- a/include/rexy/cx/hashmap.hpp +++ b/include/rexy/cx/hashmap.hpp @@ -86,7 +86,7 @@ namespace rexy::cx{ //place all keys into buckets for(auto& element : elements){ - buckets[Hash{}(element.key) % max_size].push_back(element); + buckets[Hash{}(element.key, 0) % max_size].push_back(element); } //sort the buckets based on size, largest first @@ -121,7 +121,7 @@ namespace rexy::cx{ } } //store the successful value of 'd' at index of the first hash for this bucket - m_g[Hash{}(bucket[0].key) % max_size] = d; + m_g[Hash{}(bucket[0].key, 0) % max_size] = d; //take the value from the temporary bucket into the permanent slot for(size_type i = 0;i < bucket.size();++i){ @@ -139,7 +139,7 @@ namespace rexy::cx{ break; for(;slots_used[next_free_slot];++next_free_slot); - m_g[Hash{}(bucket[0].key) % max_size] = (next_free_slot | single_bucket_bit); + m_g[Hash{}(bucket[0].key, 0) % max_size] = (next_free_slot | single_bucket_bit); m_values[next_free_slot] = std::move(bucket[0].value); slots_used[next_free_slot] = true; } @@ -149,7 +149,7 @@ namespace rexy::cx{ template template constexpr auto hashmap::operator[](U&& key)noexcept -> reference{ - auto d = m_g[UHash{}(std::forward(key)) % max_size]; + auto d = m_g[UHash{}(std::forward(key), 0) % max_size]; if(d & single_bucket_bit) return m_values[d & ~single_bucket_bit]; return m_values[UHash{}(std::forward(key), d) % max_size]; @@ -157,7 +157,7 @@ namespace rexy::cx{ template template constexpr auto hashmap::operator[](U&& key)const noexcept -> const_reference{ - auto d = m_g[UHash{}(std::forward(key)) % max_size]; + auto d = m_g[UHash{}(std::forward(key), 0) % max_size]; if(d & single_bucket_bit) return m_values[d & ~single_bucket_bit]; return m_values[UHash{}(std::forward(key), d) % max_size]; diff --git a/include/rexy/cx/string_hash.hpp b/include/rexy/cx/string_hash.hpp index 64757cf..57f9386 100644 --- a/include/rexy/cx/string_hash.hpp +++ b/include/rexy/cx/string_hash.hpp @@ -28,7 +28,7 @@ namespace rexy::cx{ //jenkns one at a time hash template struct string_hash{ - constexpr size_t operator()(const Str& s, size_t salt = 0)const noexcept{ + constexpr size_t operator()(const Str& s, size_t salt)const noexcept{ size_t hash = salt; for(size_t i = 0;i < s.length();++i){ hash += s[i];