Fix another couple of bugs with set/test.

This commit is contained in:
Jason Davies 2011-12-08 21:30:37 +00:00
parent fb2ab0c6db
commit dac2d326a0
2 changed files with 3 additions and 5 deletions

View File

@ -45,21 +45,19 @@
var l = this.locations(v),
i = -1,
k = this.k,
m = this.m,
buckets = this.buckets;
while (++i < k) buckets[Math.floor(l[i] / m)] |= 1 << (l[i] % m);
while (++i < k) buckets[Math.floor(l[i] / 32)] |= 1 << (l[i] % 32);
};
BloomFilter.prototype.test = function(v) {
var l = this.locations(v),
i = -1,
k = this.k,
m = this.m,
b,
buckets = this.buckets;
while (++i < k) {
b = l[i];
if ((buckets[Math.floor(b / m)] & (1 << (b % m))) === 0) {
if ((buckets[Math.floor(b / 32)] & (1 << (b % 32))) === 0) {
return false;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "bloomfilter",
"version": "0.0.8",
"version": "0.0.9",
"description": "Fast bloom filter in JavaScript.",
"keywords": [
"bloom filter",