TTK
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ttk::LRUCache< KeyType, ValueType > Class Template Reference

LRU cache implementation. More...

#include <Cache.h>

Public Member Functions

 LRUCache ()
 
 LRUCache (const std::size_t capacity)
 
bool empty () const
 
std::size_t capacity () const
 
std::size_t size () const
 
bool contains (const KeyType &key) const
 
void clear ()
 
void insert (const KeyType &key, const ValueType &value)
 Insert new (key, value) entry.
 
ValueType * get (const KeyType &key)
 Get value pointer from key.
 

Detailed Description

template<class KeyType, class ValueType>
class ttk::LRUCache< KeyType, ValueType >

LRU cache implementation.

Adapted from boost/compute/details/lru_cache.hpp

Definition at line 13 of file Cache.h.

Constructor & Destructor Documentation

◆ LRUCache() [1/2]

template<class KeyType , class ValueType >
ttk::LRUCache< KeyType, ValueType >::LRUCache ( )
inline

Definition at line 16 of file Cache.h.

◆ LRUCache() [2/2]

template<class KeyType , class ValueType >
ttk::LRUCache< KeyType, ValueType >::LRUCache ( const std::size_t  capacity)
inline

Definition at line 19 of file Cache.h.

Member Function Documentation

◆ capacity()

template<class KeyType , class ValueType >
std::size_t ttk::LRUCache< KeyType, ValueType >::capacity ( ) const
inline

Definition at line 26 of file Cache.h.

◆ clear()

template<class KeyType , class ValueType >
void ttk::LRUCache< KeyType, ValueType >::clear ( )
inline

Definition at line 38 of file Cache.h.

◆ contains()

template<class KeyType , class ValueType >
bool ttk::LRUCache< KeyType, ValueType >::contains ( const KeyType &  key) const
inline

Definition at line 34 of file Cache.h.

◆ empty()

template<class KeyType , class ValueType >
bool ttk::LRUCache< KeyType, ValueType >::empty ( ) const
inline

Definition at line 22 of file Cache.h.

◆ get()

template<class KeyType , class ValueType >
ValueType * ttk::LRUCache< KeyType, ValueType >::get ( const KeyType &  key)
inline

Get value pointer from key.

Returns
nullptr if cache miss

Definition at line 69 of file Cache.h.

◆ insert()

template<class KeyType , class ValueType >
void ttk::LRUCache< KeyType, ValueType >::insert ( const KeyType &  key,
const ValueType &  value 
)
inline

Insert new (key, value) entry.

Do nothing if key already in use

Definition at line 48 of file Cache.h.

◆ size()

template<class KeyType , class ValueType >
std::size_t ttk::LRUCache< KeyType, ValueType >::size ( ) const
inline

Definition at line 30 of file Cache.h.


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