LRU 알고리즘1 LRU 캐시 알고리즘 구현하기 LRU(Least Recently Used) 알고리즘은 가장 최근에 사용되지 않은 페이지를 교체하는 알고리즘입니다. 아래는 C++로 구현한 LRU 알고리즘 예시입니다. #include #include #include using namespace std; class LRUCache { private: int capacity; list cacheList; unordered_map cacheMap; public: LRUCache(int capacity) { this->capacity = capacity; } int get(int key) { if (cacheMap.find(key) == cacheMap.end()) { return -1; } auto it = cacheMap[key]; cacheList.spl.. 2023. 2. 22. 이전 1 다음