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

Method __contains__

other/lfu_cache.py:218–230  ·  view source on GitHub ↗

>>> cache = LFUCache(1) >>> 1 in cache False >>> cache.put(1, 1) >>> 1 in cache True

(self, key: T)

Source from the content-addressed store, hash-verified

216 )
217
218 def __contains__(self, key: T) -> bool:
219 """
220 >>> cache = LFUCache(1)
221
222 >>> 1 in cache
223 False
224
225 >>> cache.put(1, 1)
226 >>> 1 in cache
227 True
228 """
229
230 return key in self.cache
231
232 def get(self, key: T) -> U | None:
233 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected