TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
An implementation of LRU Cache. Lru is a part of cache algorithms (also frequently called cache replacement algorithms or cache replacement policies). More...
#include <cassert>
#include <cstdint>
#include <iostream>
#include <list>
#include <unordered_map>
Go to the source code of this file.
Classes | |
class | others::lru_cache::LRUCache |
LRU cache class. More... | |
Namespaces | |
namespace | others |
for vector | |
namespace | lru_cache |
Implementation of the LRU caching algorithm | |
Functions | |
template<typename T > | |
void | lru_tests::log (T msg) |
A function to print given message on console. | |
static void | lru_tests::test_1 () |
A simple test case The assert statement will check expected hist and miss to resultant hits and miss. | |
static void | lru_tests::test_2 () |
A test case contains hits more than cache size The assert statement will check expected hist and miss to resultant hits and miss. | |
static void | lru_tests::test_3 () |
A simple test case The assert statement will check expected hist and miss to resultant hits and miss. | |
static void | lru_tests::run_tests () |
A function to invoke all test cases. | |
int | main () |
Main function. | |
An implementation of LRU Cache. Lru is a part of cache algorithms (also frequently called cache replacement algorithms or cache replacement policies).
For a cache of page frame x:
Every time a requested page is not found in cache, that is a miss or page fault, and if the page is present in cache, then its a hit.
Definition in file lru_cache.cpp.
void lru_tests::log | ( | T | msg | ) |
A function to print given message on console.
T | Type of the given message. |
Definition at line 149 of file lru_cache.cpp.
int main | ( | void | ) |
Main function.
Definition at line 252 of file lru_cache.cpp.
|
static |
A function to invoke all test cases.
Definition at line 239 of file lru_cache.cpp.
|
static |
A simple test case The assert statement will check expected hist and miss to resultant hits and miss.
Definition at line 160 of file lru_cache.cpp.
|
static |
A test case contains hits more than cache size The assert statement will check expected hist and miss to resultant hits and miss.
Definition at line 187 of file lru_cache.cpp.
|
static |
A simple test case The assert statement will check expected hist and miss to resultant hits and miss.
Definition at line 214 of file lru_cache.cpp.