LRUCache< K, V > Class Template Reference

#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)
get_key (int index)
get_value (int index)

Private Attributes

std::vector< LRUCacheElementlist_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

Detailed Description

template<class K, class V>
class LRUCache< K, V >

Definition at line 39 of file lru_cache.h.


Member Typedef Documentation

template<class K , class V >
typedef int(* LRUCache< K, V >::lru_hash_func)(K key)

Definition at line 41 of file lru_cache.h.


Constructor & Destructor Documentation

template<class K , class V >
LRUCache< K, V >::LRUCache ( int  initial_size,
lru_hash_func  f 
) [inline]

Member Function Documentation

template<class K , class V >
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().

template<class K , class V >
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().

template<class K , class V >
int LRUCache< K, V >::hash_find ( key  )  [inline, private]
template<class K , class V >
void LRUCache< K, V >::hash_insert ( key,
int  val 
) [inline, private]
template<class K , class V >
void LRUCache< K, V >::hash_remove ( key  )  [inline, private]
template<class K , class V >
void LRUCache< K, V >::hash_reorg (  )  [inline, private]
template<class K , class V >
void LRUCache< K, V >::insert ( key,
value 
) [inline]
template<class K , class V >
int LRUCache< K, V >::list_delete_last (  )  [inline, private]
template<class K , class V >
void LRUCache< K, V >::list_insert_new ( int  pos  )  [inline, private]
template<class K , class V >
void LRUCache< K, V >::list_move_to_front ( int  index  )  [inline, private]
template<class K , class V >
void LRUCache< K, V >::list_set_keyval ( int  pos,
key,
value 
) [inline, private]

Definition at line 183 of file lru_cache.h.

References LRUCache< K, V >::list_elems.

Referenced by LRUCache< K, V >::insert().

template<class K , class V >
bool LRUCache< K, V >::lookup ( key,
V &  value 
) [inline]

Field Documentation

template<class K , class V >
int LRUCache< K, V >::bar [private]

Definition at line 61 of file lru_cache.h.

template<class K , class V >
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().

template<class K , class V >
int LRUCache< K, V >::head [private]
template<class K , class V >
std::vector<LRUCacheElement> LRUCache< K, V >::list_elems [private]
template<class K , class V >
const int LRUCache< K, V >::lru_tombstone = -2 [static, private]
template<class K , class V >
const int LRUCache< K, V >::lru_undefined = -1 [static, private]
template<class K , class V >
std::vector<int> LRUCache< K, V >::map_elems [private]
template<class K , class V >
int LRUCache< K, V >::max_hash_size [private]
template<class K , class V >
int LRUCache< K, V >::max_size [private]
template<class K , class V >
int LRUCache< K, V >::next_free [private]
template<class K , class V >
int LRUCache< K, V >::tail [private]

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1