Skip to content

Commit 9b01472

Browse files
committed
again hash_
1 parent 314237d commit 9b01472

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

data_structures/hashing/bloom_filter.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def __init__(self, size: int = 8) -> None:
7272
self.size = size
7373

7474
def add(self, value: str) -> None:
75-
h = self.hash(value)
75+
h = self.hash_(value)
7676
self.bitarray |= h
7777

7878
def exists(self, value: str) -> bool:
79-
h = self.hash(value)
79+
h = self.hash_(value)
8080
return (h & self.bitarray) == h
8181

8282
def __contains__(self, other: str) -> bool:
@@ -87,10 +87,10 @@ def format_bin(self, bitarray: int) -> str:
8787
return res.zfill(self.size)
8888

8989
@property
90-
def bitstring(self) -> None:
90+
def bitstring(self) -> str:
9191
return self.format_bin(self.bitarray)
9292

93-
def hash(self, value: str) -> int:
93+
def hash_(self, value: str) -> int:
9494
res = 0b0
9595
for func in HASH_FUNCTIONS:
9696
b = func(value.encode()).digest()
@@ -99,7 +99,7 @@ def hash(self, value: str) -> int:
9999
return res
100100

101101
def format_hash(self, value: str) -> str:
102-
return self.format_bin(self.hash(value))
102+
return self.format_bin(self.hash_(value))
103103

104104
def estimated_error_rate(self) -> float:
105105
n_ones = bin(self.bitarray).count("1")

0 commit comments

Comments
 (0)