Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1. package bloomFilter;
  2.  
  3. public class HashFunction {
  4.     Double[] v;
  5.    
  6.     public HashFunction(int m){
  7.        
  8.         v = new Double[4];
  9.        
  10.         int ff = 1000;
  11.         int pp = (int)(ff * (m + 1.76));
  12.        
  13.         if (pp%2 == 0) pp++;
  14.         while (!this.isPrime(pp)){
  15.             pp = pp + 2;
  16.         }
  17.         //The right way:
  18.         v[0] = (double)pp; //P
  19.         v[1] = Math.floor(Math.random()*(pp-1) + 1); //a
  20.         v[2] = Math.floor(Math.random()*(pp)); //b
  21.         v[3] = Math.floor(Math.random()*(pp-1) + 1); //c
  22.         return ;
  23.     }
  24.    
  25.     public boolean isPrime(int num){
  26.         for (int i = 2; i< num; i++){
  27.             if (num%i == 0){
  28.                 return false;
  29.             }
  30.         }
  31.         return true;
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement