什么是最好的哈希函数? [英] what's the best hash function?

查看:106
本文介绍了什么是最好的哈希函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是这个吗?


int hashpjw(char * str,int size)

{

unsigned long h = 0 ,g;

for(unsigned char * p =(unsigned char *)str; * p; ++ p)

{

h = (h << 4)+ * p;

if(g =(h& 0xf0000000))

{

h ^ =(g> ;> 24);

h ^ = g;

}

}

返回h%size;

}

is this?

int hashpjw(char* str,int size)
{
unsigned long h=0,g;
for(unsigned char *p=(unsigned char*)str;*p;++p)
{
h=(h<<4)+*p;
if(g=(h&0xf0000000))
{
h^=(g>>24);
h^=g;
}
}
return h%size;
}

推荐答案

" vietor.liu" < 6 ******** @ gmail.com>写道:
"vietor.liu" <vi********@gmail.com> writes:
是这个吗?
int hashpjw(char * str,int size)
{
unsigned long h = 0,g;
for(unsigned char * p =(unsigned char *)str; * p; ++ p)
{= / h =(h <4)+ * p;
if(g =(h& 0xf0000000))
{
h ^ =(g>> 24);
h ^ = g;
}
}
返回h%size;
}
is this? int hashpjw(char* str,int size)
{
unsigned long h=0,g;
for(unsigned char *p=(unsigned char*)str;*p;++p)
{
h=(h<<4)+*p;
if(g=(h&0xf0000000))
{
h^=(g>>24);
h^=g;
}
}
return h%size;
}



< OT>

答案完全取决于输入的类型和范围,

以及哈希结果的目的。继续阅读:

http://burtleburtle.net /bob/hash/evahash.html

< / OT>


-

克里斯。


<OT>
The answer totally depends on the type and range of inputs,
and the purpose of the hash result. Read onwards:

http://burtleburtle.net/bob/hash/evahash.html
</OT>

--
Chris.


On Fri,2005年11月25日10:21:54 +0800," vietor.liu"

< vi ***** ***@gmail.com>在comp.lang.c中写道:


定义最佳。
On Fri, 25 Nov 2005 10:21:54 +0800, "vietor.liu"
<vi********@gmail.com> wrote in comp.lang.c:

Define "best".
是这个吗?

int hashpjw(char * str,int size)
{
unsigned long h = 0,g;
for(unsigned char * p =(unsigned char *)str; * p; ++ p如果(g =(h& 0xf0000000))
{
h =(( g>> 24);
h ^ = g;
}
}
返回h%大小;
}
is this?

int hashpjw(char* str,int size)
{
unsigned long h=0,g;
for(unsigned char *p=(unsigned char*)str;*p;++p)
{
h=(h<<4)+*p;
if(g=(h&0xf0000000))
{
h^=(g>>24);
h^=g;
}
}
return h%size;
}




如果你想知道最佳的话哈希算法,询问

news:comp.programming。并提供您认为b $ b的定义为最佳。


一旦选择了算法,如果编码时遇到问题

在标准C中正确,然后你可以在这里发布你的代码和描述

你的问题。


-

Jack Klein

主页: http:// JK-Technology。 Com

常见问题解答

comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html

comp.lang .c ++ http://www.parashift.com/c++-faq-lite /

alt.comp.lang.learn.c-c ++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html



If you want to know the "best" hashing algorithm, ask in
news:comp.programming. And supply a definition of what you consider
to be "best".

Once you have selected an algorithm, if you have problems coding it
correctly in standard C, then you can post your code and description
of your problem here.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html


什么是th最好的颜色?


-

马布登
What is the best colour?

--
Mabden


这篇关于什么是最好的哈希函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆