惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
The GitHub Blog
The GitHub Blog
C
Check Point Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
Microsoft Security Blog
Microsoft Security Blog
爱范儿
爱范儿
Recent Announcements
Recent Announcements
阮一峰的网络日志
阮一峰的网络日志
G
GRAHAM CLULEY
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
博客园 - 司徒正美
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
Project Zero
Project Zero
云风的 BLOG
云风的 BLOG
Cisco Talos Blog
Cisco Talos Blog
Know Your Adversary
Know Your Adversary
雷峰网
雷峰网
V
V2EX - 技术
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Spread Privacy
Spread Privacy
罗磊的独立博客
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
SecWiki News
SecWiki News
Schneier on Security
Schneier on Security
O
OpenAI News
Jina AI
Jina AI
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
Y
Y Combinator Blog
Apple Machine Learning Research
Apple Machine Learning Research
B
Blog RSS Feed
I
InfoQ
D
Docker
P
Palo Alto Networks Blog
Recorded Future
Recorded Future
M
MIT News - Artificial intelligence
博客园 - Franky
B
Blog
Scott Helme
Scott Helme
博客园 - 叶小钗
D
DataBreaches.Net

博客园 - 天下大事 必作于细

boost::wave 简单就是美 My first AutoCAD journey UI testing my video card Something wrong in the msdn 租房成功 稀里糊涂去办了护照 告别紫丁香 真的很疼 继续yy 崩溃了 随感 重读《谁动了我的奶酪?》 《C++模板元编程》精彩书评(From china-pub) 五一归来后的学习计划 终于拿到auto的offer了 二面 续:关于SGI STL源码中hashtable的一点疑问
关于SGI STL源码中hashtable的一点疑问
天下大事 必作于细 · 2007-04-04 · via 博客园 - 天下大事 必作于细

   今天在研究SGI STL中的hashtable时有一点疑问一直没有想明白。

   hashtable使用hash function来计算元素位置。但是sgi使用另外一个函数bkt_num()来完成这个任务,有这个函数来调用hash function来取得一个可以对hashtable进行取模运算的值,对于char,int,long等只需要返回其值即可。但是对于string,sgi设计了一个转换函数如下:

template <class _Key> struct hash { };

inline size_t __stl_hash_string(
const char* __s)
{
  unsigned 
long __h = 0
  
for ( ; *__s; ++__s)
    __h 
= 5*__h + *__s;
  
  
return size_t(__h);
}

   这里的__h = 5*__h + *__s应该是把字符串转变成了一个long型的变量,但是采用这样的的运算进行转变有什么好处呢?为什么要乘5呢?

   希望能有达人解释一下。。。。

   也希望能够在网上搜到答案