3 ms·
I'm sorry, but this article is poorly written. The Google Knol article, http://knol.google.com/k/simple-simhashing http://knol.google.com/k/simple-simhashing ,
by ajays 16y ago
I'm sorry, but this article is poorly written. The Google Knol article, http://knol.google.com/k/simple-simhashing http://knol.google.com/k/simple-simhashing , is much better.
It is clear that the author does not understand what a hashing function is. He says, "Your programming language of choice's API will almost certainly have a few acceptable ones within arm's reach", but that's not true. Firstly, what is a programming language's "API" ? Secondly: most languages that I'm aware of have no builtin hash functions; they are usually libraries (I know, I'm getting pedantic here). And thirdly: most hash functions that you'd find in a library don't return a floating point value that you can operate on with a "min" function (or even an int value). They typically return a string of 40-, 128 or 256 bits (depending on the function). So you'll need to map the hash returned by your hash function to a value that you can compare; for example, by grabbing the last 4 bytes and treating them as an unsigned integer.
- Sinjo 16y agoHmm, I know it's a bit of an esoteric language, but Java has a method called "hashCode()" which is common to all objects, and does indeed return an int value. That's points 2 and 3 covered, I'll leave it up to you whether or not you want to split hairs on what's part of Java's "API" (a sensible reader would probably take that as the Java Class Library in the case of Java).
- sadiq 16y agohttp://docs.python.org/library/functions.html#hash http://docs.python.org/library/functions.html#hash
- rlmw 16y agoIts obvious he means standard library by 'API'. Also the type returned doesn't need to be an integer, or even a number. If you need to write a min function then the type merely needs to form a partially ordered set. A string could fulfill this requirement - simply compare an integer representation of the first character if they're equal move on to the following character. Alphabetical ordering, taught to children at all good primary schools, is a restricted version of this comparison algorithm.