Classes | Public Member Functions | Protected Attributes

CCache< T > Class Template Reference

Detailed Description

template<class T>
class shogun::CCache< T >

Template class Cache implements a simple cache.

When the cache is full -- elements that are least used are freed from the cache. Thus for the cache to be effective one should not visit loop over objects, i.e. visit elements in order 0...num_elements (with num_elements >> the maximal number of entries in cache)

Definition at line 31 of file Cache.h.

Inheritance diagram for CCache< T >:
Inheritance graph

List of all members.


struct  TEntry

Public Member Functions

 CCache (void)
 CCache (int64_t cache_size, int64_t obj_size, int64_t num_entries)
virtual ~CCache ()
bool is_cached (int64_t number)
T * lock_entry (int64_t number)
void unlock_entry (int64_t number)
T * set_entry (int64_t number)
virtual const char * get_name () const

Protected Attributes

bool cache_is_full
int64_t entry_size
int64_t nr_cache_lines
TEntry * lookup_table
TEntry ** cache_table
T * cache_block

Constructor & Destructor Documentation

CCache ( void   ) 

default constructor

Definition at line 46 of file Cache.h.

CCache ( int64_t  cache_size,
int64_t  obj_size,
int64_t  num_entries 


create a cache in which num_entries objects can be cached whose lookup table of sizeof(int64_t)*num_entries must fit into memory

cache_size cache size in Megabytes
obj_size object size
num_entries number of cached objects

Definition at line 68 of file Cache.h.

virtual ~CCache (  )  [virtual]

Definition at line 112 of file Cache.h.

Member Function Documentation

virtual const char* get_name ( void   )  const [virtual]
object name

Implements CSGObject.

Definition at line 245 of file Cache.h.

bool is_cached ( int64_t  number  ) 

checks if an object is cached

number number of object to check for
if an object is cached

Definition at line 124 of file Cache.h.

T* lock_entry ( int64_t  number  ) 

lock and get a cache entry

number number of object to lock and get
cache entry or NULL when not cached

Definition at line 134 of file Cache.h.

T* set_entry ( int64_t  number  ) 

returns the address of a free cache entry to where the data of size obj_size has to be written

number number of object to unlock
address of a free cache entry

Definition at line 163 of file Cache.h.

void unlock_entry ( int64_t  number  ) 

unlock a cache entry

number number of object to unlock

Definition at line 150 of file Cache.h.

Member Data Documentation

T* cache_block [protected]

cache block

Definition at line 259 of file Cache.h.

bool cache_is_full [protected]

if cache is full

Definition at line 249 of file Cache.h.

TEntry** cache_table [protected]

cache table containing cached objects

Definition at line 257 of file Cache.h.

int64_t entry_size [protected]

size of one entry

Definition at line 251 of file Cache.h.

TEntry* lookup_table [protected]

lookup table

Definition at line 255 of file Cache.h.

int64_t nr_cache_lines [protected]

number of cache lines

Definition at line 253 of file Cache.h.

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

SHOGUN Machine Learning Toolbox - Documentation