Aktualizovat u7/hash_table.py
This commit is contained in:
parent
0ae8311a91
commit
961d49c532
@ -1,4 +1,3 @@
|
||||
|
||||
class HashTable:
|
||||
def __init__(self, capacity=10):
|
||||
"""Vytvor prázdnu tabuľku s kladnou celočíselnou kapacitou."""
|
||||
@ -57,6 +56,17 @@ class HashTable:
|
||||
if not isinstance(key, str):
|
||||
raise TypeError("Key must be a string")
|
||||
|
||||
try:
|
||||
index = self.probe(key)
|
||||
except RuntimeError:
|
||||
return False
|
||||
|
||||
item = self._table[index]
|
||||
return (
|
||||
item is not None
|
||||
and item is not self._DELETED
|
||||
and item[0] == key
|
||||
)
|
||||
def __len__(self):
|
||||
return self._size
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user