哈希表优化
在几个哈希表实现中,我看到了对存储桶中的项目使用“转置”或“移到前面”等启发式方法。
- 使用这种启发式方法有什么优点?我自己也想不通。
- 还可以在哈希表/桶级别进行哪些其他优化,为什么以及在什么情况下进行?
请先优化散列函数。
In several hash table implementations I've seen the usage of heuristics like "transpose" or "move to front" for items in a bucket.
- What are the advantages of using such heuristics? I could't figure it out myself.
- Which other optimizations can be done at the hash table / bucket level, why, and under which circumstances?
Optimizing hashing functions aside, please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果发生冲突,因此存储桶中有多个项目,必须对其进行检查,如果常用访问的项目位于列表的前面,将会很方便。
如果有理由假设最近访问的项目可能很快会再次被访问,那么这些启发法就有意义。当人们考虑新闻报道等内容时,很可能会经常访问突发新闻。
If collisions are happening and hence buckets have several items in them, which must be examined it would be convenient if commonly accessed items were early in the list.
These heuristics make sense if there is reason to suppose that an item recently accessed is likely to be accessed again soon. When one considers something such as news stories, it's quite likely that breaking news would be accessed frequently.