MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _resize

Method _resize

data_structures/hashing/hash_map.py:114–120  ·  view source on GitHub ↗
(self, new_size: int)

Source from the content-addressed store, hash-verified

112 return len(self) < limit
113
114 def _resize(self, new_size: int) -> None:
115 old_buckets = self._buckets
116 self._buckets = [None] * new_size
117 self._len = 0
118 for item in old_buckets:
119 if item:
120 self._add_item(item.key, item.val)
121
122 def _size_up(self) -> None:
123 self._resize(len(self._buckets) * 2)

Callers 2

_size_upMethod · 0.95
_size_downMethod · 0.95

Calls 1

_add_itemMethod · 0.95

Tested by

no test coverage detected