Returns the smallest index where the number is. >>> cont = NumberContainer() >>> cont.find(10) -1 >>> cont.change(0, 10) >>> cont.find(10) 0 >>> cont.change(0, 20) >>> cont.find(10) -1 >>> cont.find(20)
(self, number: int)
| 155 | ) |
| 156 | |
| 157 | def find(self, number: int) -> int: |
| 158 | """ |
| 159 | Returns the smallest index where the number is. |
| 160 | |
| 161 | >>> cont = NumberContainer() |
| 162 | >>> cont.find(10) |
| 163 | -1 |
| 164 | >>> cont.change(0, 10) |
| 165 | >>> cont.find(10) |
| 166 | 0 |
| 167 | >>> cont.change(0, 20) |
| 168 | >>> cont.find(10) |
| 169 | -1 |
| 170 | >>> cont.find(20) |
| 171 | 0 |
| 172 | """ |
| 173 | # Simply return the 0th index (smallest) of the indexes found (or -1) |
| 174 | return self.numbermap.get(number, [-1])[0] |
| 175 | |
| 176 | |
| 177 | if __name__ == "__main__": |