/** * Test if a value is contained in the filter. * @param value The value. * @return True, if value might be contained. */ public boolean mightContain(byte[] value) { boolean ret = true; int[] hashes = hashK(value, m, k); for(int i=0; i<k && ret; ++i) { // System.out.println("hash is: "+hashes[i]); ret = bs.get(hashes[i]); } return ret; }
/** * Add a value to the filter. * @param value The value. */ public boolean add(byte[] value) { boolean ret = false; int[] hashes = hashK(value, m, k); for(int i=0; i<k; ++i) { // System.out.println("hash is: "+hashes[i]); if(!bs.get(hashes[i])) { bs.set(hashes[i]); ret = true; } } return ret; }