@Override public void add(Key key) { if (key == null) { throw new NullPointerException("key can not be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { bits.set(h[i]); keyVector[h[i]].add(key); } }
@Override public void add(Key key) { if(key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { bits.set(h[i]); } }
@Override public boolean membershipTest(Key key) { if(key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { if(!bits.get(h[i])) { return false; } } return true; }
/** * Adds a false positive information to <i>this</i> retouched Bloom filter. * <p> * <b>Invariant</b>: if the false positive is <code>null</code>, nothing happens. * @param key The false positive key to add. */ public void addFalsePositive(Key key) { if (key == null) { throw new NullPointerException("key can not be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { fpVector[h[i]].add(key); } }
@Override public boolean membershipTest(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; if((buckets[wordNum] & bucketMask) == 0) { return false; } } return true; }
@Override public void add(Key key) { if(key == null) { throw new NullPointerException("key can not be null"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only increment if the count in the bucket is less than BUCKET_MAX_VALUE if(bucketValue < BUCKET_MAX_VALUE) { // increment by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue + 1) << bucketShift); } } }
/** * Removes a given key from <i>this</i> filer. * @param k The key to remove. * @param vector The counting vector associated to the key. */ private void removeKey(Key k, List<Key>[] vector) { if (k == null) { throw new NullPointerException("Key can not be null"); } if (vector == null) { throw new NullPointerException("ArrayList<Key>[] can not be null"); } int[] h = hash.hash(k); hash.clear(); for (int i = 0; i < nbHash; i++) { vector[h[i]].remove(k); } }
int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) {
/** * Removes a specified key from <i>this</i> counting Bloom filter. * <p> * <b>Invariant</b>: nothing happens if the specified key does not belong to <i>this</i> counter Bloom filter. * @param key The key to remove. */ public void delete(Key key) { if(key == null) { throw new NullPointerException("Key may not be null"); } if(!membershipTest(key)) { throw new IllegalArgumentException("Key is not a member"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { // find the bucket int wordNum = h[i] >> 4; // div 16 int bucketShift = (h[i] & 0x0f) << 2; // (mod 16) * 4 long bucketMask = 15L << bucketShift; long bucketValue = (buckets[wordNum] & bucketMask) >>> bucketShift; // only decrement if the count in the bucket is between 0 and BUCKET_MAX_VALUE if(bucketValue >= 1 && bucketValue < BUCKET_MAX_VALUE) { // decrement by 1 buckets[wordNum] = (buckets[wordNum] & ~bucketMask) | ((bucketValue - 1) << bucketShift); } } }
int[] h = hash.hash(k);
@Override public void add(Key key) { if (key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { bits.set(h[i]); } }
@Override public boolean membershipTest(Key key) { if (key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { if (!bits.get(h[i])) { return false; } } return true; }
@Override public boolean membershipTest(final Key key) { if (key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { if (!bits.get(h[i])) { return false; } } return true; }
@Override public boolean add(final Key key) { if (key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); boolean bitsSet = false; for (int i = 0; i < nbHash; i++) { bitsSet |= !bits.get(h[i]); bits.set(h[i]); } return bitsSet; }
@Override public void add(Key key) { if (key == null) { throw new NullPointerException("key can not be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { bits.set(h[i]); keyVector[h[i]].add(key); } }
@Override public void add(Key key) { if(key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { bits.set(h[i]); } }
@Override public void add(Key key) { if (key == null) { throw new NullPointerException("key can not be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { bits.set(h[i]); keyVector[h[i]].add(key); } }
@Override public void add(Key key) { if(key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for(int i = 0; i < nbHash; i++) { bits.set(h[i]); } }
public void add(String key) { if (key == null) { throw new NullPointerException("key cannot be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { bits.set(h[i]); } }
@Override public void add(Key key) { if (key == null) { throw new NullPointerException("key can not be null"); } int[] h = hash.hash(key); hash.clear(); for (int i = 0; i < nbHash; i++) { bits.set(h[i]); keyVector[h[i]].add(key); } }