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

哈希表的遍历顺序是否有问题? #37

Closed
developerdong opened this issue Dec 22, 2021 · 1 comment
Closed

哈希表的遍历顺序是否有问题? #37

developerdong opened this issue Dec 22, 2021 · 1 comment
Assignees

Comments

@developerdong
Copy link

developerdong commented Dec 22, 2021

原文中提到

这样,遍历结果集变成:
遍历结果

按照文中描述,从3号桶的2号cell开始往后顺序遍历。但我翻看了一下文中所使用的1.9.2的源码以及最新的go1.17.5的源码,发现不管哪个Go版本,桶的遍历顺序是3->0->1->2,但每个桶内都要从offset处开始遍历,而不是前后首尾相接的遍历。所以最终的遍历顺序应该是egfcbhda,而不是efgbchad

不知道我是否理解错误,欢迎讨论。

@qcrao
Copy link
Member

qcrao commented May 15, 2022

对的。正式出版的书里已经更正过来了。谢谢指出,有兴趣可以提一个 pr~

image

@qcrao qcrao closed this as completed May 15, 2022
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