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

Method __init__

other/least_recently_used.py:37–48  ·  view source on GitHub ↗

Creates an empty store and map for the keys. The LRUCache is set the size n.

(self, n: int)

Source from the content-addressed store, hash-verified

35 _MAX_CAPACITY: int = 10 # Maximum capacity of cache
36
37 def __init__(self, n: int) -> None:
38 """Creates an empty store and map for the keys.
39 The LRUCache is set the size n.
40 """
41 self.dq_store = deque()
42 self.key_reference = set()
43 if not n:
44 LRUCache._MAX_CAPACITY = sys.maxsize
45 elif n < 0:
46 raise ValueError("n should be an integer greater than 0.")
47 else:
48 LRUCache._MAX_CAPACITY = n
49
50 def refer(self, x: T) -> None:
51 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected