MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / find

Method find

other/number_container_system.py:157–174  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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
177if __name__ == "__main__":

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected