Skip to content

Commit

Permalink
Revert previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tessil committed Jul 24, 2017
1 parent dc3c351 commit fde3676
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/hopscotch_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class mod_growth_policy {
throw std::length_error("The map exceeds its maxmimum size.");
}

const double next_bucket_count = std::ceil(m_bucket_count * REHASH_SIZE_MULTIPLICATION_FACTOR);
const double next_bucket_count = std::ceil(double(m_bucket_count) * REHASH_SIZE_MULTIPLICATION_FACTOR);
if(!std::isnormal(next_bucket_count)) {
throw std::length_error("The map exceeds its maxmimum size.");
}
Expand Down Expand Up @@ -1283,8 +1283,7 @@ class hopscotch_hash: private Hash, private KeyEqual, private GrowthPolicy {
* Hash policy
*/
float load_factor() const {
tsl_assert(bucket_count() != 0);
return m_nb_elements/float(bucket_count());
return float(m_nb_elements)/float(bucket_count());
}

float max_load_factor() const {
Expand All @@ -1293,17 +1292,17 @@ class hopscotch_hash: private Hash, private KeyEqual, private GrowthPolicy {

void max_load_factor(float ml) {
m_max_load_factor = ml;
m_load_threshold = size_type(bucket_count()*m_max_load_factor);
m_load_threshold = size_type(float(bucket_count())*m_max_load_factor);
m_min_load_factor_rehash_threshold = size_type(bucket_count()*MIN_LOAD_FACTOR_FOR_REHASH);
}

void rehash(size_type count) {
count = std::max(count, size_type(std::ceil(size()/max_load_factor())));
count = std::max(count, size_type(std::ceil(float(size())/max_load_factor())));
rehash_impl(count);
}

void reserve(size_type count) {
rehash(size_type(std::ceil(count/max_load_factor())));
rehash(size_type(std::ceil(float(count)/max_load_factor())));
}


Expand Down

0 comments on commit fde3676

Please sign in to comment.