Aktualizovat u7/hash_table.py
This commit is contained in:
parent
267d6f5a1b
commit
0ae8311a91
@ -1,10 +1,9 @@
|
||||
|
||||
|
||||
class HashTable:
|
||||
def __init__(self, capacity=10):
|
||||
"""Vytvor prázdnu tabuľku s kladnou celočíselnou kapacitou."""
|
||||
if type(capacity) is not int:
|
||||
raise TypeError("Is not integer")
|
||||
raise TypeError("It's not integer")
|
||||
if capacity <= 0:
|
||||
raise ValueError("Capacity > 0")
|
||||
|
||||
@ -22,7 +21,7 @@ class HashTable:
|
||||
def hash(self, key):
|
||||
"""Vráť polynomiálny hash kľúča modulo aktuálna kapacita."""
|
||||
if not isinstance(key, str):
|
||||
raise TypeError("Key - not string!")
|
||||
raise TypeError("Key must be a string")
|
||||
|
||||
h = 0
|
||||
for znak in key:
|
||||
@ -59,7 +58,9 @@ class HashTable:
|
||||
raise TypeError("Key must be a string")
|
||||
|
||||
def __len__(self):
|
||||
pass
|
||||
return self._size
|
||||
|
||||
def __iter__(self):
|
||||
pass
|
||||
for item in self._table:
|
||||
if item is not None and item is not self._DELETED:
|
||||
yield item[0]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user