Skip to content

关于dictRehash的疑问 #26

@zhugeliuyun

Description

@zhugeliuyun

while(de) {
uint64_t h;
nextde = de->next;
/* Get the index in the new hash table */
h = dictHashKey(d, de->key) & d->ht[1].sizemask;
de->next = d->ht[1].table[h];
d->ht[1].table[h] = de;
d->ht[0].used--;
d->ht[1].used++;
de = nextde;
}
以上代码是int dictRehash(dict *d, int n)中的部分实现,对于d->ht[0].used--有疑问,由于我们使用链接法解决冲突,所以de节点后面链接的所有节点理论上并没有记录在d->ht[0].used中,所以这里不是很明白,希望大神能帮我解惑。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions