TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Examples of quick hash tables and dynamic arrays in C

29 点作者 grep_it4 个月前

2 条评论

kccqzy4 个月前
My understanding of the word &quot;quick&quot; in the title is that this code is quick to write. But then this brings up the question of why. Why do we prioritize code that is easy to write, which presumably means it needs to be written over and over again. Is this a reflection of the sad state of C library packaging?<p>A quick perusal of the hashmap landscape[0] in C++ shows a vibrant ecosystem where newer and faster implementations appear every year or so.<p>[0]: <a href="https:&#x2F;&#x2F;martin.ankerl.com&#x2F;2022&#x2F;08&#x2F;27&#x2F;hashmap-bench-01&#x2F;" rel="nofollow">https:&#x2F;&#x2F;martin.ankerl.com&#x2F;2022&#x2F;08&#x2F;27&#x2F;hashmap-bench-01&#x2F;</a>
评论 #42793712 未加载
评论 #42793714 未加载
评论 #42793643 未加载
liontwist4 个月前
The hash table is still doing a string compare per bucket.<p>The best technique I have seen is to have an open addressing hash table whose keys are 64 bit hashes and values are pointers.<p>Then you layer on top of that to make a string dictionary. The value of the hash table is a linked list chain of key value pairs where the key is a string.<p>In the vast majority of cases you never touch the chain. Only when two keys have identical 64 bit hashes (not bucket indices) do you need to disambiguate with string equality.<p>This design is much faster and can be easily reconfigured for key types which are not strings, with no changes to the underlying hash table.
评论 #42793634 未加载
评论 #42794703 未加载