new
This commit is contained in:
parent
3281c53834
commit
19572c7785
@ -53,3 +53,18 @@ class HashTable:
|
|||||||
return first_deleted
|
return first_deleted
|
||||||
|
|
||||||
raise RuntimeError("Tabuľka je plná")
|
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
|
||||||
Loading…
Reference in New Issue
Block a user