We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 454eded commit 2c99889Copy full SHA for 2c99889
data_structures/hashing/hash_map.py
@@ -228,6 +228,28 @@ def __delitem__(self, key: KEY) -> None:
228
Traceback (most recent call last):
229
...
230
KeyError: 4
231
+
232
+ # Test resize down when sparse
233
+ ## Setup: resize up
234
+ >>> hm = HashMap(100, capacity_factor=0.75)
235
+ >>> len(hm._buckets)
236
+ 100
237
+ >>> for i in range(75):
238
+ ... hm[i] = i
239
240
241
+ >>> hm[75] = 75
242
243
+ 200
244
245
+ ## Resize down
246
+ >>> for i in range(38, 76):
247
+ ... del hm[i]
248
249
250
+ >>> del hm[37]
251
252
253
"""
254
for ind in self._iterate_buckets(key):
255
item = self._buckets[ind]
0 commit comments