mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
Update hash map
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user