Base Framework
Public Types | Public Member Functions | Public Attributes | Related Functions | List of all members
Cache< KEY, VALUE > Class Template Reference

Cache. More...

#include <base/collection/Cache.h>

Inherits Collection.

Public Types

typedef KEY Key
 
typedef VALUE Value
 

Public Member Functions

 Cache () noexcept
 
 Cache (MemorySize capacity)
 
 Cache (const Cache &copy) noexcept
 
Cacheoperator= (const Cache &assign) noexcept
 
MemorySize getSize () const noexcept
 
bool isEmpty () const noexcept
 
bool isCached (const Key &key) const noexcept
 
const Value & getValue (const Key &key) const
 
void add (const Key &key, const Value &value)
 
void remove (const Key &key)
 
void removeAll () noexcept
 
HashTable< KEY, VALUE >::Element operator[] (const Key &key)
 
const Value & operator[] (const Key &key) const
 

Public Attributes

HashTable< KEY, VALUE > elements
 

Related Functions

(Note that these are not member functions.)

template<class KEY , class VALUE >
FormatOutputStreamoperator<< (FormatOutputStream &stream, const Cache< KEY, VALUE > &value)
 

Detailed Description

template<class KEY, class VALUE>
class Cache< KEY, VALUE >

Cache.

Cache implementation.

Version
1.0

Constructor & Destructor Documentation

◆ Cache() [1/3]

template<class KEY , class VALUE >
Cache< KEY, VALUE >::Cache ( )
inlinenoexcept

Initializes the cache.

◆ Cache() [2/3]

template<class KEY , class VALUE >
Cache< KEY, VALUE >::Cache ( MemorySize  capacity)
inline

Initializes the cache with the specified initial capacity.

◆ Cache() [3/3]

template<class KEY , class VALUE >
Cache< KEY, VALUE >::Cache ( const Cache< KEY, VALUE > &  copy)
inlinenoexcept

Initializes cache from other cache.

Member Function Documentation

◆ add()

template<class KEY , class VALUE >
void Cache< KEY, VALUE >::add ( const Key &  key,
const Value &  value 
)
inline

Adds the key and value to the cache.

◆ getSize()

template<class KEY , class VALUE >
MemorySize Cache< KEY, VALUE >::getSize ( ) const
inlinenoexcept

Returns the number of elements in the cache.

◆ getValue()

template<class KEY , class VALUE >
const Value& Cache< KEY, VALUE >::getValue ( const Key &  key) const
inline

Returns the value associated with the specified key. Raises InvalidKey if the specified key doesn't exist in the cache.

Parameters
keyThe key of the value.

◆ isCached()

template<class KEY , class VALUE >
bool Cache< KEY, VALUE >::isCached ( const Key &  key) const
inlinenoexcept

Returns true if the specified object is in the cache.

◆ isEmpty()

template<class KEY , class VALUE >
bool Cache< KEY, VALUE >::isEmpty ( ) const
inlinenoexcept

Returns true if the cache is empty.

◆ operator=()

template<class KEY , class VALUE >
Cache& Cache< KEY, VALUE >::operator= ( const Cache< KEY, VALUE > &  assign)
inlinenoexcept

Assignment of cache by cache.

◆ operator[]() [1/2]

template<class KEY , class VALUE >
HashTable<KEY, VALUE>::Element Cache< KEY, VALUE >::operator[] ( const Key &  key)
inline

Returns the value associated with the specified key when used as 'rvalue'. When used as 'lvalue' the key is associated with the specified value.

◆ operator[]() [2/2]

template<class KEY , class VALUE >
const Value& Cache< KEY, VALUE >::operator[] ( const Key &  key) const
inline

Returns the value associated with the specified key.

◆ remove()

template<class KEY , class VALUE >
void Cache< KEY, VALUE >::remove ( const Key &  key)
inline

Removes the specified key and its associated value from this cache. Raises InvalidKey if the key doesn't exist in the cache.

◆ removeAll()

template<class KEY , class VALUE >
void Cache< KEY, VALUE >::removeAll ( )
inlinenoexcept

Removes all the keys from the cache.

Friends And Related Function Documentation

◆ operator<<()

template<class KEY , class VALUE >
FormatOutputStream & operator<< ( FormatOutputStream stream,
const Cache< KEY, VALUE > &  value 
)
related

Writes the content of the cache to the format output stream.

Member Data Documentation

◆ elements

template<class KEY , class VALUE >
HashTable<KEY, VALUE> Cache< KEY, VALUE >::elements

The values in the cache.