Motivation
Description
Currently, the repository lacks a standardized implementation of an LRU (Least Recently Used) Cache. This is a fundamental data structure in computer science used for memory management and caching strategies.
Proposed Solution
I propose adding an LRU Cache implementation that achieves O(1) time complexity for both get and put operations by combining:
- A Doubly Linked List: To maintain the order of elements based on their usage.
- A Hash Map (Map): To provide fast access to nodes by their keys.
Implementation Details
- BaseCache (Abstract Class): Defines the contract for cache implementations, demonstrating OOP abstraction.
- LRUCache (Concrete Class): Extends
BaseCache and manages the pointer logic for eviction and updates.
- Generics: Supports any key-value types
<K, V>.
- Unit Tests: Comprehensive coverage for eviction, updates, and capacity constraints.
I have already implemented this locally and would like to contribute it.
Examples
No response
Possible workarounds
No response
Motivation
Description
Currently, the repository lacks a standardized implementation of an LRU (Least Recently Used) Cache. This is a fundamental data structure in computer science used for memory management and caching strategies.
Proposed Solution
I propose adding an LRU Cache implementation that achieves O(1) time complexity for both
getandputoperations by combining:Implementation Details
BaseCacheand manages the pointer logic for eviction and updates.<K, V>.I have already implemented this locally and would like to contribute it.
Examples
No response
Possible workarounds
No response