Skip to content

Commit f103a45

Browse files
committed
Added doctest to hash_map.py
1 parent 21f85af commit f103a45

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: data_structures/hashing/hash_map.py

+14
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,20 @@ def __getitem__(self, key: KEY) -> VAL:
253253
raise KeyError(key)
254254

255255
def __len__(self) -> int:
256+
"""
257+
Returns the number of items present in hashmap
258+
259+
>>> hm = HashMap(5)
260+
>>> hm._add_item(1, 10)
261+
>>> hm._add_item(2, 20)
262+
>>> hm._add_item(3, 30)
263+
>>> hm.__len__()
264+
3
265+
266+
>>> hm = HashMap(5)
267+
>>> hm.__len__()
268+
0
269+
"""
256270
return self._len
257271

258272
def __iter__(self) -> Iterator[KEY]:

0 commit comments

Comments
 (0)