what's the best hash function?

V

vietor.liu

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;
}
 
J

Jack Klein

On Fri, 25 Nov 2005 10:21:54 +0800, "vietor.liu"

Define "best".
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;
}

If you want to know the "best" hashing algorithm, ask in
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.
 
J

Joe Estock

Mabden said:
What is the best colour?

Red. No wait, Purple. On second thought, make that Green.

I have no idea what it is you are asking since both the subject line and
the body of your post are completely different and no context is
provided in either. Please be more descriptive when you post as it helps
us better help you.

Joe
 
D

David Resnick

Christopher said:
And what is the airspeed velocity of an unladen swallow?

This really sounds like homework. Besides, it is an algorithm
question, so comp.programming would be a better place.
Maybe you should try to write a C program to calculate
the average velocity of a number of swallows. If you
present your efforts, I'm sure people will try to give you a
hand. <OT> Hint -- it matters whether it is African or
European </OT>

-David
 
J

Jordan Abel

Red. No wait, Purple. On second thought, make that Green.

I have no idea what it is you are asking since both the subject line and
the body of your post are completely different and no context is
provided in either. Please be more descriptive when you post as it helps
us better help you.

It seems to me that he's responding to the question in the subject with
a rhetorical question, rather than responding to the body of the post he
is in reply to.
 
M

Mabden

Richard Heathfield said:
Joe Estock said:


' . .
ea e o ee e o a
Pl s d n t f d th tr lls Th nks

Buuuuurrrrp!

Seriously, it was an answer to the post. How can one say what the best
hash function is without knowing the data? I think my answer was quite
appropos.
 
J

Joe Estock

Mabden said:
Buuuuurrrrp!

Seriously, it was an answer to the post. How can one say what the best
hash function is without knowing the data? I think my answer was quite
appropos.

If enough of the original post were left in your reply then I would be
inclined to agree, however I had nothing but the text I replied to and
misinterpreted your reply. Yet another classic example of why you should
quote enough text from the previous post so that someone looking at the
thread for the very first time has enough information to understand your
reply. For all I know you could have been the OP replying to your
original thread.

Joe
 
M

Mabden

Joe Estock said:
If enough of the original post were left in your reply then I would be
inclined to agree, however I had nothing but the text I replied to and
misinterpreted your reply. Yet another classic example of why you should
quote enough text from the previous post so that someone looking at the
thread for the very first time has enough information to understand your
reply. For all I know you could have been the OP replying to your
original thread.


It really wouldn't help. The subject says it all, but here it is, in all
its 2-word glory:
======================
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;
}

======================

Now, does that really need to have been included. I think not.

I await your apology with anticip...
..
..
..
..
ation
 
J

Joe Estock

Mabden wrote:
[snip irrelevant stuff to my reply]
It really wouldn't help. The subject says it all, but here it is, in all
its 2-word glory:
======================
is this?
[snip 14 lines of code for hash function]
======================

Now, does that really need to have been included. I think not.

I agree that it did not need to be included, however you could have at
least included some context such as [snip useless function] so that
others who do not have access to the original thread can better
understand why you replied as you did.
I await your apology with anticip...
[snip gratuitous waste of newlines]

None needed since I said nothing that demands an apology. I was simply
pointing out that if you had quoted (or at least noted that you trimmed)
the original post that I would not have replied as I did. You don't read
the last message in a thread without first reading the original post and
neither do I.

Joe
 
J

Jordan Abel

I await your apology with anticip...
[snip gratuitous waste of newlines]

it's not like we're killing trees, here - they probably only occupy a
byte apiece in storage and two over the wire. Your complaint was almost
certainly bigger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top