|
ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
|
A hash map with a size limit. When full, the least recently used half is dropped, so entries in use every frame stay cached. More...
#include <lru_cache.h>
Classes | |
| struct | Entry |
Public Member Functions | |
| LruCache (std::size_t limit) | |
| template<typename K > | |
| Value * | find (const K &key) |
| Find an entry and mark it used. | |
| Value & | insert (Key key, Value value) |
| Add or replace an entry, dropping old entries first when full. | |
| void | clear () |
| std::size_t | size () const |
Private Member Functions | |
| void | evict () |
Private Attributes | |
| std::unordered_map< Key, Entry, Hash, Equal > | _map |
| std::vector< uint64_t > | _stamps |
| std::size_t | _limit |
| uint64_t | _clock { 0 } |
A hash map with a size limit. When full, the least recently used half is dropped, so entries in use every frame stay cached.
Hash and Equal may be transparent, so find() can take a key view that does not allocate.
Definition at line 23 of file lru_cache.h.
|
inlineexplicit |
Definition at line 25 of file lru_cache.h.
|
inline |
Definition at line 55 of file lru_cache.h.
|
inlineprivate |
Definition at line 73 of file lru_cache.h.
|
inline |
Find an entry and mark it used.
Definition at line 32 of file lru_cache.h.
|
inline |
Add or replace an entry, dropping old entries first when full.
Definition at line 44 of file lru_cache.h.
|
inline |
Definition at line 60 of file lru_cache.h.
|
private |
Definition at line 99 of file lru_cache.h.
|
private |
Definition at line 98 of file lru_cache.h.
|
private |
Definition at line 96 of file lru_cache.h.
|
private |
Definition at line 97 of file lru_cache.h.