Skip to content

Instantly share code, notes, and snippets.

@bluescarni
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bluescarni/1230a547cbabc31147ec to your computer and use it in GitHub Desktop.
Save bluescarni/1230a547cbabc31147ec to your computer and use it in GitHub Desktop.
const hash_set::iterator begin = B.begin(), end = B.end();
for (auto &a: A) {
for (hash_set::iterator it = begin; it != end; ++it) {
temp.first = a.first + it->first;
size_t bucket = C._bucket(temp);
auto it = C._find(temp, bucket);
if (it == C.end()) {
// Check it the load factor of C is too large.
if ((double(C.size()) + 1) / C.bucket_count() > C.max_load_factor()) {
// Increase the size of the table.
container._increase_size();
// Recompute the bucker.
bucket = C._bucket(temp);
}
temp.second = a.second * it->second;
C._unique_insert(temp, bucket);
C._update_size(C.size() + 1u);
} else {
piranha::math::multiply_accumulate(it->second,a.second,it->second);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment