Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e6ce098

Browse files
committed
type hints
1 parent 4111807 commit e6ce098

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

data_structures/hashing/bloom_filter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def __init__(self, size=8):
1414
self.bitstring = 0b0
1515
self.size = size
1616

17-
def add(self, value):
17+
def add(self, value: str):
1818
h = self.hash_(value)
1919
self.bitstring |= h
2020
print(
@@ -25,7 +25,7 @@ def add(self, value):
2525
"""
2626
)
2727

28-
def exists(self, value):
28+
def exists(self, value: str)-> bool:
2929
h = self.hash_(value)
3030
res = (h & self.bitstring) == h
3131

@@ -39,11 +39,11 @@ def exists(self, value):
3939
)
4040
return res
4141

42-
def format_bin(self, value):
42+
def format_bin(self, value: int) -> str:
4343
res = bin(value)[2:]
4444
return res.zfill(self.size)
4545

46-
def hash_(self, value):
46+
def hash_(self, value: str) -> int:
4747
res = 0b0
4848
for func in self.HASH_FUNCTIONS:
4949
b = func(value.encode()).digest()

0 commit comments

Comments
 (0)