other.least_recently_used ========================= .. py:module:: other.least_recently_used Attributes ---------- .. autoapisummary:: other.least_recently_used.T other.least_recently_used.lru_cache Classes ------- .. autoapisummary:: other.least_recently_used.LRUCache Module Contents --------------- .. py:class:: LRUCache(n: int) Bases: :py:obj:`Generic`\ [\ :py:obj:`T`\ ] Page Replacement Algorithm, Least Recently Used (LRU) Caching. >>> lru_cache: LRUCache[str | int] = LRUCache(4) >>> lru_cache.refer("A") >>> lru_cache.refer(2) >>> lru_cache.refer(3) >>> lru_cache LRUCache(4) => [3, 2, 'A'] >>> lru_cache.refer("A") >>> lru_cache LRUCache(4) => ['A', 3, 2] >>> lru_cache.refer(4) >>> lru_cache.refer(5) >>> lru_cache LRUCache(4) => [5, 4, 'A', 3] .. py:method:: __repr__() -> str .. py:method:: display() -> None Prints all the elements in the store. .. py:method:: refer(x: T) -> None Looks for a page in the cache store and adds reference to the set. Remove the least recently used key if the store is full. Update store to reflect recent access. .. py:attribute:: _MAX_CAPACITY :type: int :value: 10 .. py:attribute:: dq_store :type: collections.deque[T] .. py:attribute:: key_reference :type: set[T] .. py:data:: T .. py:data:: lru_cache :type: LRUCache[str | int]