Remove hash default arguments

This commit is contained in:
rexy712 2020-05-07 11:58:59 -07:00
parent ef5cccee73
commit 0318efe1e6
3 changed files with 7 additions and 7 deletions

View File

@ -25,7 +25,7 @@ namespace rexy::cx{
template<class T>
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<size_t>(t);
size_t hash = 5381 + salt; //magic hash number

View File

@ -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<class Key, class Value, size_t N, class Hash>
template<class U, class UHash>
constexpr auto hashmap<Key,Value,N,Hash>::operator[](U&& key)noexcept -> reference{
auto d = m_g[UHash{}(std::forward<U>(key)) % max_size];
auto d = m_g[UHash{}(std::forward<U>(key), 0) % max_size];
if(d & single_bucket_bit)
return m_values[d & ~single_bucket_bit];
return m_values[UHash{}(std::forward<U>(key), d) % max_size];
@ -157,7 +157,7 @@ namespace rexy::cx{
template<class Key, class Value, size_t N, class Hash>
template<class U, class UHash>
constexpr auto hashmap<Key,Value,N,Hash>::operator[](U&& key)const noexcept -> const_reference{
auto d = m_g[UHash{}(std::forward<U>(key)) % max_size];
auto d = m_g[UHash{}(std::forward<U>(key), 0) % max_size];
if(d & single_bucket_bit)
return m_values[d & ~single_bucket_bit];
return m_values[UHash{}(std::forward<U>(key), d) % max_size];

View File

@ -28,7 +28,7 @@ namespace rexy::cx{
//jenkns one at a time hash
template<class Str>
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];