Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于dictRehash的疑问 #26

Open
zhugeliuyun opened this issue Jun 29, 2018 · 1 comment
Open

关于dictRehash的疑问 #26

zhugeliuyun opened this issue Jun 29, 2018 · 1 comment

Comments

@zhugeliuyun
Copy link

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中,所以这里不是很明白,希望大神能帮我解惑。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants