Returns the number of items present in hashmap >>> hm = HashMap(5) >>> hm._add_item(1, 10) >>> hm._add_item(2, 20) >>> hm._add_item(3, 30) >>> hm.__len__() 3 >>> hm = HashMap(5) >>> hm.__len__() 0
(self)
| 295 | raise KeyError(key) |
| 296 | |
| 297 | def __len__(self) -> int: |
| 298 | """ |
| 299 | Returns the number of items present in hashmap |
| 300 | |
| 301 | >>> hm = HashMap(5) |
| 302 | >>> hm._add_item(1, 10) |
| 303 | >>> hm._add_item(2, 20) |
| 304 | >>> hm._add_item(3, 30) |
| 305 | >>> hm.__len__() |
| 306 | 3 |
| 307 | |
| 308 | >>> hm = HashMap(5) |
| 309 | >>> hm.__len__() |
| 310 | 0 |
| 311 | """ |
| 312 | return self._len |
| 313 | |
| 314 | def __iter__(self) -> Iterator[KEY]: |
| 315 | yield from (item.key for item in self._buckets if item) |
nothing calls this directly
no outgoing calls
no test coverage detected