Fix the code of hash map chaining.

This commit is contained in:
krahets
2023-08-01 17:05:40 +08:00
parent 55615ab61d
commit 6da6d24193
7 changed files with 79 additions and 61 deletions

View File

@ -80,10 +80,12 @@ class HashMapChaining {
List<Pair> bucket = buckets.get(index);
// 遍历桶,从中删除键值对
for (Pair pair : bucket) {
if (pair.key == key)
if (pair.key == key) {
bucket.remove(pair);
size--;
break;
}
}
size--;
}
/* 扩容哈希表 */