MCPcopy
hub / github.com/keon/algorithms / put

Method put

algorithms/data_structures/hash_table.py:160–169  ·  view source on GitHub ↗

Insert or update, resizing if load factor exceeds two-thirds. Args: key: The key to insert. value: The value associated with the key.

(self, key: int, value: object)

Source from the content-addressed store, hash-verified

158 super().__init__(self.MIN_SIZE)
159
160 def put(self, key: int, value: object) -> None:
161 """Insert or update, resizing if load factor exceeds two-thirds.
162
163 Args:
164 key: The key to insert.
165 value: The value associated with the key.
166 """
167 super().put(key, value)
168 if len(self) >= (self.size * 2) / 3:
169 self._resize()
170
171 def _resize(self) -> None:
172 """Double the table size and rehash all existing entries."""

Callers 2

_resizeMethod · 0.95

Calls 2

_resizeMethod · 0.95
putMethod · 0.45

Tested by 1