Database Reference
In-Depth Information
try {
outputs[i].writeObject(arg0);
outputs[i].flush();
int j = hashes[i].hash() % m;
if(counters[j] < Byte. MAX_VALUE )
counters[j]++;
if(counters[j] == 1) added = true;
} catch(IOException e) { }
}
return added;
}
The remove(E arg0) method is also easily implemented, taking into
account the fact that the counter has overflowed:
public boolean remove(E arg0) {
boolean removed = false;
for(int i=0;i<outputs.length;i++) {
hashes[i].reset();
try {
outputs[i].writeObject(arg0);
outputs[i].flush();
int j = hashes[i].hash() % m;
if(counters[j] > 0 && counters[j] <
Byte. MAX_VALUE )
counters[j]--;
if(counters[j] == 0) removed = true;
} catch(IOException e) { }
}
return removed;
}
Implementing the test for set membership is then as simple as making
sure all the counters are positive—the same as the original Bloom Filter
implementation:
public boolean contains(Object arg0) {
for(int i=0;i<outputs.length;i++) {
try {
Search WWH ::




Custom Search