Several bug fixes.

This commit is contained in:
krahets
2023-10-04 02:30:31 +08:00
parent 0e3d2ce4bb
commit 4355f8d49f
7 changed files with 8 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ class HashMapChaining {
}
/* 查询操作 */
public string get(int key) {
public string? get(int key) {
int index = hashFunc(key);
// 遍历桶,若找到 key 则返回对应 val
foreach (Pair pair in buckets[index]) {

View File

@@ -59,7 +59,7 @@ class HashMapOpenAddressing {
}
/* 查询操作 */
public string get(int key) {
public string? get(int key) {
// 搜索 key 对应的桶索引
int index = findBucket(key);
// 若找到键值对,则返回对应 val