This commit is contained in:
Vadym Afanasiev 2026-10-29 14:08:10 +00:00
parent 3281c53834
commit 19572c7785

View File

@ -53,3 +53,18 @@ class HashTable:
return first_deleted
raise RuntimeError("Tabuľka je plná")
def load_factor(self):
return self._size / self.__capacity
def _resize(self):
old_slots = self.slots
self.__capacity *= 2
self.slots = [self.empty] * self.__capacity
self._size = 0
for slot in old_slots:
if slot is not self.empty and slot is not self.deleted:
key, value = slot
index = self.probe(key)
self.slots[index] = (key, value)
self.size += 1