我正在寻找一种在我的Java项目中使用(universal) family of pairwise independent hash functions的快捷方法。
理想情况下,我会有一些对象UniversalFamily
(代表Family),它会返回带有哈希整数的方法hash()
的对象。
使用示例:
// use this object to generate pairwise independent hash functions
UniversalFamily family = new UniversalFamily();
// these objects represent the pairwise independent hash functions
HashF hashF1 = fam.getHashFunction();
HashF hashF2 = fam.getHashFunction();
// ...
/* here the hash functions are being used to hash the integers 1, 2 and
1337, the return values (not stored) are the results of the
corresponding hash functions. */
hashF1.hash(1);
hashF1.hash(2);
hashF2.hash(1337);
// ...
在我开始摆弄之前,有没有这样的东西可用?
答案 0 :(得分:0)
使用类似的东西:
def censor(sentence, word):
return " ".join([w if w != word else "*"*len(w) for w in sentence.split(" ")])