Advertisement
TimSenin

Untitled

Nov 17th, 2022
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. bool Insert(const K& key, const V& value) {
  2.     std::lock_guard<std::mutex> lg(mutexes_[hash_(key) % table_.size() % mutexes_.size()]);
  3.     size_t bucket_id = hash_(key) % table_.size();
  4.     for (auto& [k, v] : table_[bucket_id]) {
  5.         if (k == key) {
  6.             return false;
  7.         }
  8.     }
  9.     table_[bucket_id].emplace_back(key, value);
  10.     size_.store(size_.load() + 1);
  11.     return true;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement