![]() |
TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
LRU cache class. More...
Public Member Functions | |
| LRUCache (uint64_t pf) | |
| Constructor, Initialize thee LRU class with page frame. | |
| void | refer (uint64_t page) |
| Refer to a page, or request a page from memory. | |
| void | display () |
| A function to display the current cache. | |
| uint64_t | getHits () const |
| A function to get page hits. | |
| uint64_t | getPageFault () const |
| A function to get page fault. | |
Private Attributes | |
| uint64_t | pageFrame |
| Page frame, or total size of the cache. | |
| std::list< uint64_t > | cache |
| Cache linked list (using the STL). | |
| std::unordered_map< uint64_t, std::list< uint64_t >::iterator > | pageMap |
| Hash map containing pages and their addresses. | |
| uint64_t | hits |
| was found in cache. | |
| uint64_t | pageFault = 0 |
LRU cache class.
Definition at line 68 of file lru_cache.cpp.
|
inlineexplicit |
Constructor, Initialize thee LRU class with page frame.
| pf | Page frame or total size of cache. |
Definition at line 85 of file lru_cache.cpp.
|
inline |
A function to display the current cache.
Definition at line 121 of file lru_cache.cpp.
|
inline |
|
inline |
|
inline |
Refer to a page, or request a page from memory.
| page | The page that you are referring to. |
< Increase the page fault by one.
Definition at line 92 of file lru_cache.cpp.
|
private |
Cache linked list (using the STL).
Definition at line 70 of file lru_cache.cpp.
|
private |
was found in cache.
Total number of hits, or total number of times a page
Definition at line 74 of file lru_cache.cpp.
|
private |
Total number of miss/page fault, or total number of times a page was not found in cache
Definition at line 77 of file lru_cache.cpp.
|
private |
Page frame, or total size of the cache.
Definition at line 69 of file lru_cache.cpp.
|
private |
Hash map containing pages and their addresses.
Definition at line 72 of file lru_cache.cpp.