Re: Best way to hash a set of integers?



"Digital Puer" <digital_puer@xxxxxxxxxxx> writes:

However, I'm still looking for info on how to best hash a *set*
of integers; do I add them, XOR them, multiply them, etc. to
get a final key? What are best practices?

That this was what you wanted wasn't clear to me at first. It's
a more interesting question that hashing a single integer.

I would suggest XOR'ing the integers, then using an integer hash
algorithm on the composite value. Of course, whether XOR is the
best function to use depends on properties of the sets. Can you
tell us anything about the sets?
--
"The fact is, technical people are better off not looking at patents. If
you don't know what they cover and where they are, you won't be knowingly
infringing on them. If somebody sues you, you change the algorithm or you
just hire a hit-man to whack the stupid git." --Linus Torvalds
.



Relevant Pages

  • Re: puzzle
    ... >> One real problem, however, with the XOR algorithm is that it assumes ... Using XOR, you just happen to get lucky, in the sense that XOR just ... It didn't state that the language, in which the algorithm was written ... I had to beat the XOR solution out of you. ...
    (comp.programming)
  • Re: puzzle
    ... Mike wrote: ... this remains a stunning irrevelance to the fact that the XOR ... Even if the bitwise representation is not accessible any ... The algorithm will still be O. ...
    (comp.programming)
  • Re: puzzle
    ... this remains a stunning irrevelance to the fact that the XOR ... Even if the bitwise representation is not accessible any ... The algorithm will still be O. ... Then all of our XOR solutions will fail and he will ...
    (comp.programming)
  • Re: puzzle
    ... If you exclude XOR, for bouned numbers, the same solution can be written ... The result is an Oalgorithm that ... I found, as you have, that puzzles make bad pedagogic tools. ... You'd have to ask the students if it actually worked, ...
    (comp.programming)
  • Re: Algorithm to compare two binary numbers
    ... >> The algorithm does not necessarily have to be restricted to 1 byte ... 256-entry lookup table would be faster than a real-time, bit counting ... 10,000,000 XOR operations, and need to count the bits of every XOR result, ... either by lookup table or by a real-time counting function. ...
    (comp.programming)