mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Fix the code of hash map chaining.
This commit is contained in:
@ -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--;
|
||||
}
|
||||
|
||||
/* 扩容哈希表 */
|
||||
|
||||
Reference in New Issue
Block a user