Database Reference
In-Depth Information
The implementation of cardinality() typically uses parallel counting
tricks to improve performance, but it will still operate in O(m) time. If this
method is going to be called many times, better performance is achieved by
integrating the computation of X into the add() method as follows:
public boolean add(E arg0) {
if(!contains(arg0)) {
for(int i=0;i<outputs.length;i++) {
hashes[i].reset();
try {
outputs[i].writeObject(arg0);
outputs[i].flush();
int h = hashes[i].hash() % m;
X += bits.get(h) ? 0 : 1;
bits.set(h);
} catch(IOException e) { }
}
return true;
}
return false;
}
The reset() method is also modified to set X back to zero when the filter is
reset.
Search WWH ::




Custom Search