如何将一个SDBM哈希函数在C#中实现? [英] How would a sdbm hash function be implemented in C#?
本文介绍了如何将一个SDBM哈希函数在C#中实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
How can a sdbm
hash function (such as this) be implemented in C# ?
推荐答案
您可以几乎不用修改C代码:
You can take the C code almost without changes:
uint sdbm( string str )
{
uint hash = 0;
foreach( char ch in str )
{
hash = ch + (hash << 6) + (hash << 16) - hash;
}
return hash;
}
或者你觉得更复杂吗?
这篇关于如何将一个SDBM哈希函数在C#中实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文