Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bloomFilter;
- public class HashFunction {
- Double[] v;
- public HashFunction(int m){
- v = new Double[4];
- int ff = 1000;
- int pp = (int)(ff * (m + 1.76));
- if (pp%2 == 0) pp++;
- while (!this.isPrime(pp)){
- pp = pp + 2;
- }
- //The right way:
- v[0] = (double)pp; //P
- v[1] = Math.floor(Math.random()*(pp-1) + 1); //a
- v[2] = Math.floor(Math.random()*(pp)); //b
- v[3] = Math.floor(Math.random()*(pp-1) + 1); //c
- return ;
- }
- public boolean isPrime(int num){
- for (int i = 2; i< num; i++){
- if (num%i == 0){
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement