CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold > Class Template Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold > Class Template Reference

Templated fixed size cache class. More...

`#include <csutil/fixedsizecache.h>`

List of all members.

## Public Member Functions
bool | Get (const K &key, T &data)
| Get a possibly existing item in cache.
bool | Insert (const K &key, const T &data)
| Insert an element and key into the cache.
void | InsertOrUpdate (const K &key, const T &data)
| Update an existing element in the cache, inserting it if needed.
void | Update (const K &key, const T &data)
| Update an existing element in the cache.

## Detailed Description

### template<typename K, typename T, unsigned int CacheSize, unsigned int Associativity = 1, typename LRUPolicy = FixedSizeBestChoiceLRUPolicy, typename HashFold = CS::Utility::HashFoldingFNV1>
class CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold >

Templated fixed size cache class.

The cache can be organized as a 1-way, N-way (where N is a power of two) or fully associative cache.

Parameters:

  K | Key type used to index the cache. Must be hashable and comparable.
  T | Data type stored in cache. Must be copy-constructable.
  CacheSize | Number of elements in total in cache
  Associativity | Associativity of cache. 0 means fully associative.
  LRUPolicy | Template policy for the per set cache eviction LRU.

Definition at line 806 of file fixedsizecache.h.

## Member Function Documentation

template<typename K , typename T , unsigned int CacheSize, unsigned int Associativity = 1, typename LRUPolicy = FixedSizeBestChoiceLRUPolicy, typename HashFold = CS::Utility::HashFoldingFNV1>

bool CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold >::Get | ( | const K & | key,
|  | T & | data
| ) |  | `[inline]`

Get a possibly existing item in cache.

Parameters:

  key | Cache item key
  data | Cached data. Updated on successful retrieval from cache.

Returns:
  true if item exists in cache.

Definition at line 879 of file fixedsizecache.h.

template<typename K , typename T , unsigned int CacheSize, unsigned int Associativity = 1, typename LRUPolicy = FixedSizeBestChoiceLRUPolicy, typename HashFold = CS::Utility::HashFoldingFNV1>

bool CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold >::Insert | ( | const K & | key,
|  | const T & | data
| ) |  | `[inline]`

Insert an element and key into the cache.

If key already exists, no update will happen

Parameters:

  key | Cache item key
  data | Cache item data

Returns:
  true if insert is successful

Definition at line 826 of file fixedsizecache.h.

template<typename K , typename T , unsigned int CacheSize, unsigned int Associativity = 1, typename LRUPolicy = FixedSizeBestChoiceLRUPolicy, typename HashFold = CS::Utility::HashFoldingFNV1>

void CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold >::InsertOrUpdate | ( | const K & | key,
|  | const T & | data
| ) |  | `[inline]`

Update an existing element in the cache, inserting it if needed.

Parameters:

  key | Cache item key
  data | New data for cached item

Definition at line 861 of file fixedsizecache.h.

template<typename K , typename T , unsigned int CacheSize, unsigned int Associativity = 1, typename LRUPolicy = FixedSizeBestChoiceLRUPolicy, typename HashFold = CS::Utility::HashFoldingFNV1>

void CS::Utility::FixedSizeCache< K, T, CacheSize, Associativity, LRUPolicy, HashFold >::Update | ( | const K & | key,
|  | const T & | data
| ) |  | `[inline]`

Update an existing element in the cache.

If the key is non-existent it will not be added

Parameters:

  key | Cache item key
  data | New data for cached item

Definition at line 844 of file fixedsizecache.h.

The documentation for this class was generated from the following file:

- csutil/fixedsizecache.h