| 33 | from typing import Iterator, MutableMapping |
| 34 | |
| 35 | class SortedDict(MutableMapping[str, int]): |
| 36 | def __init__(self) -> None: |
| 37 | self.data: Dict[str, int] = {} |
| 38 | |
| 39 | def __getitem__(self, key: str) -> int: |
| 40 | return self.data[key] |
| 41 | |
| 42 | def __setitem__(self, key: str, value: int) -> None: |
| 43 | self.data[key] = value |
| 44 | |
| 45 | def __delitem__(self, key: str) -> None: |
| 46 | del self.data[key] |
| 47 | |
| 48 | def __iter__(self) -> Iterator[str]: |
| 49 | keys = list(self.data.keys()) |
| 50 | keys.sort() |
| 51 | for key in keys: |
| 52 | yield key |
| 53 | |
| 54 | def __len__(self) -> int: |
| 55 | return len(self.data) |
| 56 | |
| 57 | |
| 58 | votes = { |
no outgoing calls
no test coverage detected