We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8f6d86d commit d413a4eCopy full SHA for d413a4e
1 file changed
ConcurrentHashMap.h
@@ -46,8 +46,17 @@ class ConcurrentHashMap {
46
std::size_t hashValue = hashFunction(key);
47
std::size_t index = hashValue % buckets.size();
48
49
+ Node* current = buckets[index].empty() ? nullptr : buckets[index][0]; // Cast to Node*
50
+ while (current != nullptr) {
51
+ if (current->key == key) {
52
+ current->value = value; // Update the value
53
+ return; // Found the key
54
+ }
55
+ current = current->next; // No need to cast here
56
57
+
58
Node* newNode = new Node(key, value);
- newNode->next = buckets[index].empty() ? nullptr : buckets[index][0]; // Cast to Node*
59
+ newNode->next = buckets[index].empty() ? nullptr : buckets[index][0]; // Cast to Node*
60
buckets[index] = {newNode};
61
}
62
0 commit comments