Skip to content

Commit

Permalink
[#204] Fixed a bug in Erase function in Local Multimap
Browse files Browse the repository at this point in the history
  • Loading branch information
VitoCastellana committed May 3, 2023
1 parent 32ada02 commit 8001425
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions include/shad/data_structures/local_multimap.h
Original file line number Diff line number Diff line change
Expand Up @@ -916,16 +916,13 @@ void LocalMultimap<KTYPE, VTYPE, KEY_COMPARE>::Erase(const KTYPE &key) {
// loop over entries in this bucket
for (size_t i = 0; i < bucket->BucketSize(); ++i) {
Entry *entry = &bucket->getEntry(i);

// Reached first unused entry, key not found, return
if (entry->state == EMPTY) {
release_deleter(bucketIdx);
return;
break;
}

// If key does not match this entry's key, continue inner for loop
if (KeyComp_(&entry->key, &key) != 0) continue;

// Key found
numberKeys_ -= 1;

Expand Down Expand Up @@ -989,6 +986,7 @@ void LocalMultimap<KTYPE, VTYPE, KEY_COMPARE>::Erase(const KTYPE &key) {
bucket = bucket->next.get();
}
} // First outer for loop
release_deleter(bucketIdx);
}

template <typename KTYPE, typename VTYPE, typename KEY_COMPARE>
Expand Down

0 comments on commit 8001425

Please sign in to comment.