Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Insert(const K& key, const V& value) {
- std::lock_guard<std::mutex> lg(mutexes_[hash_(key) % table_.size() % mutexes_.size()]);
- size_t bucket_id = hash_(key) % table_.size();
- for (auto& [k, v] : table_[bucket_id]) {
- if (k == key) {
- return false;
- }
- }
- table_[bucket_id].emplace_back(key, value);
- size_.store(size_.load() + 1);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement