#include <lru_cache.h>
Data Structures | |
| struct | LRUCacheElement |
Public Types | |
| typedef int(* | lru_hash_func )(K key) |
Public Member Functions | |
| LRUCache (int initial_size, lru_hash_func f) | |
| void | insert (K key, V value) |
| bool | lookup (K key, V &value) |
Private Member Functions | |
| void | hash_reorg () |
| int | hash_find (K key) |
| void | hash_insert (K key, int val) |
| void | hash_remove (K key) |
| void | list_move_to_front (int index) |
| int | list_delete_last () |
| void | list_insert_new (int pos) |
| void | list_set_keyval (int pos, K key, V value) |
| K | get_key (int index) |
| V | get_value (int index) |
Private Attributes | |
| std::vector< LRUCacheElement > | list_elems |
| std::vector< int > | map_elems |
| int | next_free |
| int | max_size |
| int | max_hash_size |
| int | head |
| int | tail |
| lru_hash_func | hash_func |
| int | bar |
Static Private Attributes | |
| static const int | lru_undefined = -1 |
| static const int | lru_tombstone = -2 |
Definition at line 39 of file lru_cache.h.
| typedef int(* LRUCache< K, V >::lru_hash_func)(K key) |
Definition at line 41 of file lru_cache.h.
| LRUCache< K, V >::LRUCache | ( | int | initial_size, | |
| lru_hash_func | f | |||
| ) | [inline] |
Definition at line 197 of file lru_cache.h.
References LRUCache< K, V >::list_elems, LRUCache< K, V >::lru_undefined, LRUCache< K, V >::map_elems, LRUCache< K, V >::max_hash_size, and LRUCache< K, V >::max_size.
| K LRUCache< K, V >::get_key | ( | int | index | ) | [inline, private] |
Definition at line 188 of file lru_cache.h.
References LRUCache< K, V >::list_elems.
Referenced by LRUCache< K, V >::insert().
| V LRUCache< K, V >::get_value | ( | int | index | ) | [inline, private] |
Definition at line 192 of file lru_cache.h.
References LRUCache< K, V >::list_elems.
Referenced by LRUCache< K, V >::lookup().
| int LRUCache< K, V >::hash_find | ( | K | key | ) | [inline, private] |
Definition at line 80 of file lru_cache.h.
References LRUCache< K, V >::hash_func, LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::list_elems, LRUCache< K, V >::lru_tombstone, LRUCache< K, V >::lru_undefined, LRUCache< K, V >::map_elems, and LRUCache< K, V >::max_hash_size.
Referenced by LRUCache< K, V >::hash_remove(), LRUCache< K, V >::insert(), and LRUCache< K, V >::lookup().
| void LRUCache< K, V >::hash_insert | ( | K | key, | |
| int | val | |||
| ) | [inline, private] |
Definition at line 101 of file lru_cache.h.
References LRUCache< K, V >::hash_func, LRUCache< K, V >::lru_tombstone, LRUCache< K, V >::lru_undefined, LRUCache< K, V >::map_elems, and LRUCache< K, V >::max_hash_size.
Referenced by LRUCache< K, V >::hash_reorg(), and LRUCache< K, V >::insert().
| void LRUCache< K, V >::hash_remove | ( | K | key | ) | [inline, private] |
Definition at line 118 of file lru_cache.h.
References LRUCache< K, V >::hash_find(), LRUCache< K, V >::lru_tombstone, LRUCache< K, V >::lru_undefined, and LRUCache< K, V >::map_elems.
Referenced by LRUCache< K, V >::insert().
| void LRUCache< K, V >::hash_reorg | ( | ) | [inline, private] |
Definition at line 66 of file lru_cache.h.
References LRUCache< K, V >::hash_insert(), LRUCache< K, V >::head, LRUCache< K, V >::list_elems, LRUCache< K, V >::lru_undefined, LRUCache< K, V >::map_elems, LRUCache< K, V >::max_hash_size, LRUCache< K, V >::max_size, and LRUCache< K, V >::next_free.
Referenced by LRUCache< K, V >::hash_find().
| void LRUCache< K, V >::insert | ( | K | key, | |
| V | value | |||
| ) | [inline] |
Definition at line 214 of file lru_cache.h.
References LRUCache< K, V >::get_key(), LRUCache< K, V >::hash_find(), LRUCache< K, V >::hash_insert(), LRUCache< K, V >::hash_remove(), LRUCache< K, V >::list_delete_last(), LRUCache< K, V >::list_insert_new(), LRUCache< K, V >::list_move_to_front(), LRUCache< K, V >::list_set_keyval(), LRUCache< K, V >::lru_undefined, LRUCache< K, V >::map_elems, LRUCache< K, V >::max_size, and LRUCache< K, V >::next_free.
| int LRUCache< K, V >::list_delete_last | ( | ) | [inline, private] |
Definition at line 153 of file lru_cache.h.
References LRUCache< K, V >::head, LRUCache< K, V >::list_elems, LRUCache< K, V >::lru_undefined, LRUCache< K, V >::max_size, LRUCache< K, V >::next_free, and LRUCache< K, V >::tail.
Referenced by LRUCache< K, V >::insert().
| void LRUCache< K, V >::list_insert_new | ( | int | pos | ) | [inline, private] |
Definition at line 167 of file lru_cache.h.
References LRUCache< K, V >::head, LRUCache< K, V >::list_elems, LRUCache< K, V >::lru_undefined, and LRUCache< K, V >::tail.
Referenced by LRUCache< K, V >::insert().
| void LRUCache< K, V >::list_move_to_front | ( | int | index | ) | [inline, private] |
Definition at line 125 of file lru_cache.h.
References LRUCache< K, V >::head, LRUCache< K, V >::list_elems, LRUCache< K, V >::lru_undefined, LRUCache< K, V >::max_size, and LRUCache< K, V >::tail.
Referenced by LRUCache< K, V >::insert(), and LRUCache< K, V >::lookup().
| void LRUCache< K, V >::list_set_keyval | ( | int | pos, | |
| K | key, | |||
| V | value | |||
| ) | [inline, private] |
Definition at line 183 of file lru_cache.h.
References LRUCache< K, V >::list_elems.
Referenced by LRUCache< K, V >::insert().
| bool LRUCache< K, V >::lookup | ( | K | key, | |
| V & | value | |||
| ) | [inline] |
Definition at line 239 of file lru_cache.h.
References LRUCache< K, V >::get_value(), LRUCache< K, V >::hash_find(), LRUCache< K, V >::list_move_to_front(), LRUCache< K, V >::lru_undefined, and LRUCache< K, V >::map_elems.
Definition at line 61 of file lru_cache.h.
lru_hash_func LRUCache< K, V >::hash_func [private] |
Definition at line 59 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_find(), and LRUCache< K, V >::hash_insert().
Definition at line 57 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::list_delete_last(), LRUCache< K, V >::list_insert_new(), and LRUCache< K, V >::list_move_to_front().
std::vector<LRUCacheElement> LRUCache< K, V >::list_elems [private] |
Definition at line 52 of file lru_cache.h.
Referenced by LRUCache< K, V >::get_key(), LRUCache< K, V >::get_value(), LRUCache< K, V >::hash_find(), LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::list_delete_last(), LRUCache< K, V >::list_insert_new(), LRUCache< K, V >::list_move_to_front(), LRUCache< K, V >::list_set_keyval(), and LRUCache< K, V >::LRUCache().
const int LRUCache< K, V >::lru_tombstone = -2 [static, private] |
Definition at line 63 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_find(), LRUCache< K, V >::hash_insert(), and LRUCache< K, V >::hash_remove().
const int LRUCache< K, V >::lru_undefined = -1 [static, private] |
Definition at line 62 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_find(), LRUCache< K, V >::hash_insert(), LRUCache< K, V >::hash_remove(), LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::insert(), LRUCache< K, V >::list_delete_last(), LRUCache< K, V >::list_insert_new(), LRUCache< K, V >::list_move_to_front(), LRUCache< K, V >::lookup(), and LRUCache< K, V >::LRUCache().
Definition at line 53 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_find(), LRUCache< K, V >::hash_insert(), LRUCache< K, V >::hash_remove(), LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::insert(), LRUCache< K, V >::lookup(), and LRUCache< K, V >::LRUCache().
int LRUCache< K, V >::max_hash_size [private] |
Definition at line 56 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_find(), LRUCache< K, V >::hash_insert(), LRUCache< K, V >::hash_reorg(), and LRUCache< K, V >::LRUCache().
Definition at line 55 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::insert(), LRUCache< K, V >::list_delete_last(), LRUCache< K, V >::list_move_to_front(), and LRUCache< K, V >::LRUCache().
Definition at line 54 of file lru_cache.h.
Referenced by LRUCache< K, V >::hash_reorg(), LRUCache< K, V >::insert(), and LRUCache< K, V >::list_delete_last().
Definition at line 58 of file lru_cache.h.
Referenced by LRUCache< K, V >::list_delete_last(), LRUCache< K, V >::list_insert_new(), and LRUCache< K, V >::list_move_to_front().
1.6.1