mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 18:00:18 +08:00
build
This commit is contained in:
@@ -2896,7 +2896,7 @@ comments: true
|
||||
hashMap->capacity = 4;
|
||||
hashMap->loadThres = 2.0 / 3.0;
|
||||
hashMap->extendRatio = 2;
|
||||
hashMap->buckets = (Pair **)malloc(sizeof(Pair *) * hashMap->capacity);
|
||||
hashMap->buckets = (Pair **)calloc(hashMap->capacity, sizeof(Pair *));
|
||||
hashMap->TOMBSTONE = (Pair *)malloc(sizeof(Pair));
|
||||
hashMap->TOMBSTONE->key = -1;
|
||||
hashMap->TOMBSTONE->val = "-1";
|
||||
@@ -3015,7 +3015,7 @@ comments: true
|
||||
int oldCapacity = hashMap->capacity;
|
||||
// 初始化扩容后的新哈希表
|
||||
hashMap->capacity *= hashMap->extendRatio;
|
||||
hashMap->buckets = (Pair **)malloc(sizeof(Pair *) * hashMap->capacity);
|
||||
hashMap->buckets = (Pair **)calloc(hashMap->capacity, sizeof(Pair *));
|
||||
hashMap->size = 0;
|
||||
// 将键值对从原哈希表搬运至新哈希表
|
||||
for (int i = 0; i < oldCapacity; i++) {
|
||||
|
||||
Reference in New Issue
Block a user