Esempio n. 1
0
    def __init__(self,
                 b: int = 14,
                 hashfunc: Optional[Callable] = None,
                 hashbits: Optional[int] = None) -> None:

        assert b >= 4 and logical_xnor(hashfunc, hashbits)

        self.b = b

        if hashfunc:
            self.hash = hashfunc
        else:
            self.hash = hash

        if hashbits:
            self.width = hashbits
        else:
            self.width = bitness()

        self.maxsize = 2**self.width

        self.m = 2**self.b

        if self.m == 16:
            self.alpha = 0.673
        elif self.m == 32:
            self.alpha = 0.697
        elif self.m == 64:
            self.alpha = 0.709
        else:
            self.alpha = 0.7213 / (1 + 1.079 / self.m)

        self.registers = [0] * self.m
Esempio n. 2
0
	def test_logical_xnor_nonbool(self, a, b, truth):
		result = logical_xnor(a, b)
		self.assertEqual(truth, result)