19 lines
632 B
Python
19 lines
632 B
Python
class HashTable:
|
|
def __init__(self, capacity=10):
|
|
if type(capacity) is not int:
|
|
raise TypeError("Kapacita musí byť celé číslo (int)")
|
|
if capacity <= 0:
|
|
raise ValueError("Kapacita musí byť kladné číslo")
|
|
self.__capacity = capacity
|
|
self._size = 0
|
|
|
|
self.empty = object()
|
|
self.deleted = object()
|
|
self.slots = [self.empty] * self.__capacity
|
|
|
|
@property
|
|
def capacity(self):
|
|
return self.__capacity
|
|
def _check_key(self, key):
|
|
if not isinstance(key, str):
|
|
raise TypeError("Kľúč musí byť reťazec (str)") |