Tatooine
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
tatooine::cache< Key, Value > Class Template Reference

#include <cache.h>

Inheritance diagram for tatooine::cache< Key, Value >:
[legend]
Collaboration diagram for tatooine::cache< Key, Value >:
[legend]

Public Types

using container_type = std::map< Key, Value >
 
using const_iterator = typename container_type::const_iterator
 
using usage_type = std::list< const_iterator >
 

Public Member Functions

 cache (uint64_t max_elements=std::numeric_limits< uint64_t >::max(), uint64_t max_memory_usage=std::numeric_limits< uint64_t >::max())
 
 cache (const cache &other)
 
 cache (cache &&other)=default
 
auto & operator= (const cache &other)
 
cacheoperator= (cache &&other)=default
 
auto insert (const Key &key, const Value &value)
 
auto insert (Key &&key, const Value &value)
 
auto insert (const Key &key, Value &&value)
 
auto insert (Key &&key, Value &&value)
 
template<typename... Args>
auto emplace (const Key &key, Args &&... args)
 
const auto & operator[] (const Key &key) const
 
auto & operator[] (const Key &key)
 
const auto & at (const Key &key) const
 
auto & at (const Key &key)
 
std::optional< const_iteratorcontains (const Key &key) const
 
bool is_cached (const Key &key) const
 
auto size () const
 
void clear ()
 

Private Member Functions

void capacity_check ()
 
void enqueue (const_iterator it, bool ins)
 
void refresh_usage (const_iterator it)
 

Private Attributes

container_type m_data
 
usage_type m_usage
 
uint64_t m_max_elements
 
uint64_t m_max_memory_usage
 

Member Typedef Documentation

◆ const_iterator

template<typename Key , typename Value >
using tatooine::cache< Key, Value >::const_iterator = typename container_type::const_iterator

◆ container_type

template<typename Key , typename Value >
using tatooine::cache< Key, Value >::container_type = std::map<Key, Value>

◆ usage_type

template<typename Key , typename Value >
using tatooine::cache< Key, Value >::usage_type = std::list<const_iterator>

Constructor & Destructor Documentation

◆ cache() [1/3]

template<typename Key , typename Value >
tatooine::cache< Key, Value >::cache ( uint64_t  max_elements = std::numeric_limits<uint64_t>::max(),
uint64_t  max_memory_usage = std::numeric_limits<uint64_t>::max() 
)
inline

◆ cache() [2/3]

template<typename Key , typename Value >
tatooine::cache< Key, Value >::cache ( const cache< Key, Value > &  other)
inline

◆ cache() [3/3]

template<typename Key , typename Value >
tatooine::cache< Key, Value >::cache ( cache< Key, Value > &&  other)
default

Member Function Documentation

◆ at() [1/2]

template<typename Key , typename Value >
auto & tatooine::cache< Key, Value >::at ( const Key &  key)
inline

◆ at() [2/2]

template<typename Key , typename Value >
const auto & tatooine::cache< Key, Value >::at ( const Key &  key) const
inline

◆ capacity_check()

template<typename Key , typename Value >
void tatooine::cache< Key, Value >::capacity_check ( )
inlineprivate

◆ clear()

template<typename Key , typename Value >
void tatooine::cache< Key, Value >::clear ( )
inline

◆ contains()

template<typename Key , typename Value >
std::optional< const_iterator > tatooine::cache< Key, Value >::contains ( const Key &  key) const
inline

◆ emplace()

template<typename Key , typename Value >
template<typename... Args>
auto tatooine::cache< Key, Value >::emplace ( const Key &  key,
Args &&...  args 
)
inline

◆ enqueue()

template<typename Key , typename Value >
void tatooine::cache< Key, Value >::enqueue ( const_iterator  it,
bool  ins 
)
inlineprivate

◆ insert() [1/4]

template<typename Key , typename Value >
auto tatooine::cache< Key, Value >::insert ( const Key &  key,
const Value &  value 
)
inline

◆ insert() [2/4]

template<typename Key , typename Value >
auto tatooine::cache< Key, Value >::insert ( const Key &  key,
Value &&  value 
)
inline

◆ insert() [3/4]

template<typename Key , typename Value >
auto tatooine::cache< Key, Value >::insert ( Key &&  key,
const Value &  value 
)
inline

◆ insert() [4/4]

template<typename Key , typename Value >
auto tatooine::cache< Key, Value >::insert ( Key &&  key,
Value &&  value 
)
inline

◆ is_cached()

template<typename Key , typename Value >
bool tatooine::cache< Key, Value >::is_cached ( const Key &  key) const
inline

◆ operator=() [1/2]

template<typename Key , typename Value >
cache & tatooine::cache< Key, Value >::operator= ( cache< Key, Value > &&  other)
default

◆ operator=() [2/2]

template<typename Key , typename Value >
auto & tatooine::cache< Key, Value >::operator= ( const cache< Key, Value > &  other)
inline

◆ operator[]() [1/2]

template<typename Key , typename Value >
auto & tatooine::cache< Key, Value >::operator[] ( const Key &  key)
inline

◆ operator[]() [2/2]

template<typename Key , typename Value >
const auto & tatooine::cache< Key, Value >::operator[] ( const Key &  key) const
inline

◆ refresh_usage()

template<typename Key , typename Value >
void tatooine::cache< Key, Value >::refresh_usage ( const_iterator  it)
inlineprivate

◆ size()

template<typename Key , typename Value >
auto tatooine::cache< Key, Value >::size ( ) const
inline

Member Data Documentation

◆ m_data

template<typename Key , typename Value >
container_type tatooine::cache< Key, Value >::m_data
private

◆ m_max_elements

template<typename Key , typename Value >
uint64_t tatooine::cache< Key, Value >::m_max_elements
private

◆ m_max_memory_usage

template<typename Key , typename Value >
uint64_t tatooine::cache< Key, Value >::m_max_memory_usage
private

◆ m_usage

template<typename Key , typename Value >
usage_type tatooine::cache< Key, Value >::m_usage
mutableprivate

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