I am in the process of learning about bloom filters and I am looking through various hash functions in JavaScript.
For example I found this one in another Stack Overflow answer:
Found here https://stackoverflow.com/a/7616484/5217568)
String.prototype.hashCode = function() {
var hash = 0, i, chr, len;
if (this.length == 0) return hash;
for (i = 0, len = this.length; i < len; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
If I run:
String.prototype.call(null, "hello")
I get the numerical value of : 99162322 (two other hash functions got me: 1335831723, and 120092131).
Now If I create a hypothetical bloom filter with 3 hash functions, and 18 indices (k=3, m=18), How are these large values indexed in an array with indices from 0-17?