mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 14:43:43 +00:00
type hints
This commit is contained in:
parent
4111807c47
commit
e6ce09836d
|
@ -14,7 +14,7 @@ class Bloom:
|
|||
self.bitstring = 0b0
|
||||
self.size = size
|
||||
|
||||
def add(self, value):
|
||||
def add(self, value: str):
|
||||
h = self.hash_(value)
|
||||
self.bitstring |= h
|
||||
print(
|
||||
|
@ -25,7 +25,7 @@ class Bloom:
|
|||
"""
|
||||
)
|
||||
|
||||
def exists(self, value):
|
||||
def exists(self, value: str)-> bool:
|
||||
h = self.hash_(value)
|
||||
res = (h & self.bitstring) == h
|
||||
|
||||
|
@ -39,11 +39,11 @@ class Bloom:
|
|||
)
|
||||
return res
|
||||
|
||||
def format_bin(self, value):
|
||||
def format_bin(self, value: int) -> str:
|
||||
res = bin(value)[2:]
|
||||
return res.zfill(self.size)
|
||||
|
||||
def hash_(self, value):
|
||||
def hash_(self, value: str) -> int:
|
||||
res = 0b0
|
||||
for func in self.HASH_FUNCTIONS:
|
||||
b = func(value.encode()).digest()
|
||||
|
|
Loading…
Reference in New Issue
Block a user