CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy > 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::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy > Class Template Reference

One set in an associative cache. More...

`#include <csutil/fixedsizecache.h>`

List of all members.

## Public Member Functions
ElementType * | Find (const K &key)
| Find an element with given key in set.
| FixedSizeCacheSet ()
| Initialize an empty cache set.
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 set.
void | InsertOrUpdate (const K &key, const T &data)
| Update an existing element in the cache, inserting it if needed.
void | Invalidate (const K &key)
| Invalidate the data associated with given key, without remving the key itself.
void | Update (const K &key, const T &data)
| Update an existing element in the set.
| ~FixedSizeCacheSet ()
| Destroy any remaning items in cache set.

## Detailed Description

### template<typename K, typename T, unsigned int SetSize, typename LRUPolicy>
class CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >

One set in an associative cache.

Holds a power-of-two number of elements, subject to replacement using a LRU policy.

Parameters:

  K | Key type used to index the cache. Must be hashable and comparable.
  T | Data type stored in cache. Must be copy-constructable.
  SetSize | Number of elements in set.
  LRUPolicy | Template policy for the cache eviction LRU.

Definition at line 111 of file fixedsizecache.h.

## Constructor & Destructor Documentation

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::FixedSizeCacheSet | ( |  | ) | `[inline]`

Initialize an empty cache set.

Definition at line 119 of file fixedsizecache.h.

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::~FixedSizeCacheSet | ( |  | ) | `[inline]`

Destroy any remaning items in cache set.

Definition at line 126 of file fixedsizecache.h.

## Member Function Documentation

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

ElementType* CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::Find | ( | const K & | key | ) | `[inline]`

Find an element with given key in set.

Parameters:

  key | Cache item key

Returns:
  the element if found, otherwise 0

Definition at line 230 of file fixedsizecache.h.

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

bool CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::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 251 of file fixedsizecache.h.

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

bool CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::Insert | ( | const K & | key,
|  | const T & | data
| ) |  | `[inline]`

Insert an element and key into the set.

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 149 of file fixedsizecache.h.

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

void CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::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 197 of file fixedsizecache.h.

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

void CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::Invalidate | ( | const K & | key | ) | `[inline]`

Invalidate the data associated with given key, without remving the key itself.

Definition at line 266 of file fixedsizecache.h.

template<typename K , typename T , unsigned int SetSize, typename LRUPolicy >

void CS::Utility::Implementation::FixedSizeCacheSet< K, T, SetSize, LRUPolicy >::Update | ( | const K & | key,
|  | const T & | data
| ) |  | `[inline]`

Update an existing element in the set.

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 175 of file fixedsizecache.h.

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

- csutil/fixedsizecache.h