1.RSHash unsigned int RSHash(const std::string& str) { unsigned int b = 378551; unsigned int a = 63689; unsigned int hash = 0; for(std::size_t i = 0; i < str.length(); i++) { hash = hash * a + str[i]; a = a * b…
对于海量字符串的查找,一般有两种方法,一种是建树,还有一种就是bf算法,即布隆过滤器,这个从原来上讲比较简单,也易于实现,主要就是根据哈希算法来实现. int len(char *ch) { int m=0; while(ch[m]!='\0') { m++; } return m; } bool judge(char *vertor,char ch[]){ if (GETBIT(vertor,RSHash(ch,len(ch)))==0) return false; if (GETBIT(ve…
unsigned int RSHash(const std::string& str) { unsigned int b = 378551; unsigned int a = 63689; unsigned int hash = 0; for(std::size_t i = 0; i < str.length(); i++) { hash = hash * a + str[i]; a = a * b; // 这保证对于每个字符串 处理出的值 相同的概率很小 a 可能会自然爆 long lon…