Update hash map

This commit is contained in:
Yudong Jin
2022-12-15 23:08:07 +08:00
parent 1229f98e92
commit c071ab88d2
6 changed files with 13 additions and 8 deletions

View File

@ -53,7 +53,7 @@ public:
/* 删除操作 */
void remove(int key) {
int index = hashFunc(key);
// 置为空字符,代表删除
// 置为 nullptr ,代表删除
bucket[index] = nullptr;
}
@ -97,6 +97,8 @@ public:
}
}
};
/* Driver Code */
int main() {
/* 初始化哈希表 */
ArrayHashMap map = ArrayHashMap();
@ -139,4 +141,4 @@ int main() {
}
return 0;
}
}

View File

@ -7,6 +7,7 @@
#include "../include/include.hpp"
/* Driver Code */
int main() {
/* 初始化哈希表 */
unordered_map<int, string> map;
@ -49,4 +50,4 @@ int main() {
}
return 0;
}
}