Cadabra
Computer algebra system for field theory problems
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
LRUcache< Key, Value, Compare > Class Template Reference

#include <lru_cache.hh>

Public Types

using value_type = std::pair< Key, Value >
 
using List = std::list< value_type >
 
using iterator = typename List::iterator
 
using const_iterator = typename List::const_iterator
 
using size_type = size_t
 

Public Member Functions

 LRUcache (size_t capacity)
 
void touch (iterator &it)
 
Value & at (const Key &key, bool touching=true)
 
void insert (const Key &key, const Value &value)
 
Value & operator[] (const Key &key)
 
iterator find (const Key &key, bool touching=true)
 
bool contains (const Key &key, bool touching=true)
 
size_t erase (const Key &key)
 
iterator erase (const_iterator &it)
 
iterator erase (iterator &it)
 
void clear ()
 
bool empty () const
 
size_t size () const
 
void resize (size_t new_size)
 
iterator begin ()
 
iterator end ()
 

Private Member Functions

void evict ()
 

Private Attributes

List cache_list
 
std::map< Key, iterator, Compare > cache_lookup
 
size_t max_size
 

Member Typedef Documentation

◆ const_iterator

template<typename Key , typename Value , typename Compare = std::less<Key>>
using LRUcache< Key, Value, Compare >::const_iterator = typename List::const_iterator

◆ iterator

template<typename Key , typename Value , typename Compare = std::less<Key>>
using LRUcache< Key, Value, Compare >::iterator = typename List::iterator

◆ List

template<typename Key , typename Value , typename Compare = std::less<Key>>
using LRUcache< Key, Value, Compare >::List = std::list<value_type>

◆ size_type

template<typename Key , typename Value , typename Compare = std::less<Key>>
using LRUcache< Key, Value, Compare >::size_type = size_t

◆ value_type

template<typename Key , typename Value , typename Compare = std::less<Key>>
using LRUcache< Key, Value, Compare >::value_type = std::pair<Key, Value>

Constructor & Destructor Documentation

◆ LRUcache()

template<typename Key , typename Value , typename Compare = std::less<Key>>
LRUcache< Key, Value, Compare >::LRUcache ( size_t  capacity)
inline

Member Function Documentation

◆ at()

template<typename Key , typename Value , typename Compare = std::less<Key>>
Value& LRUcache< Key, Value, Compare >::at ( const Key &  key,
bool  touching = true 
)
inline

◆ begin()

template<typename Key , typename Value , typename Compare = std::less<Key>>
iterator LRUcache< Key, Value, Compare >::begin ( )
inline

◆ clear()

template<typename Key , typename Value , typename Compare = std::less<Key>>
void LRUcache< Key, Value, Compare >::clear ( )
inline

◆ contains()

template<typename Key , typename Value , typename Compare = std::less<Key>>
bool LRUcache< Key, Value, Compare >::contains ( const Key &  key,
bool  touching = true 
)
inline

◆ empty()

template<typename Key , typename Value , typename Compare = std::less<Key>>
bool LRUcache< Key, Value, Compare >::empty ( ) const
inline

◆ end()

template<typename Key , typename Value , typename Compare = std::less<Key>>
iterator LRUcache< Key, Value, Compare >::end ( )
inline

◆ erase() [1/3]

template<typename Key , typename Value , typename Compare = std::less<Key>>
size_t LRUcache< Key, Value, Compare >::erase ( const Key &  key)
inline

◆ erase() [2/3]

template<typename Key , typename Value , typename Compare = std::less<Key>>
iterator LRUcache< Key, Value, Compare >::erase ( const_iterator it)
inline

◆ erase() [3/3]

template<typename Key , typename Value , typename Compare = std::less<Key>>
iterator LRUcache< Key, Value, Compare >::erase ( iterator it)
inline

◆ evict()

template<typename Key , typename Value , typename Compare = std::less<Key>>
void LRUcache< Key, Value, Compare >::evict ( )
inlineprivate

◆ find()

template<typename Key , typename Value , typename Compare = std::less<Key>>
iterator LRUcache< Key, Value, Compare >::find ( const Key &  key,
bool  touching = true 
)
inline

◆ insert()

template<typename Key , typename Value , typename Compare = std::less<Key>>
void LRUcache< Key, Value, Compare >::insert ( const Key &  key,
const Value &  value 
)
inline

◆ operator[]()

template<typename Key , typename Value , typename Compare = std::less<Key>>
Value& LRUcache< Key, Value, Compare >::operator[] ( const Key &  key)
inline

◆ resize()

template<typename Key , typename Value , typename Compare = std::less<Key>>
void LRUcache< Key, Value, Compare >::resize ( size_t  new_size)
inline

◆ size()

template<typename Key , typename Value , typename Compare = std::less<Key>>
size_t LRUcache< Key, Value, Compare >::size ( ) const
inline

◆ touch()

template<typename Key , typename Value , typename Compare = std::less<Key>>
void LRUcache< Key, Value, Compare >::touch ( iterator it)
inline

Member Data Documentation

◆ cache_list

template<typename Key , typename Value , typename Compare = std::less<Key>>
List LRUcache< Key, Value, Compare >::cache_list
private

◆ cache_lookup

template<typename Key , typename Value , typename Compare = std::less<Key>>
std::map<Key, iterator, Compare> LRUcache< Key, Value, Compare >::cache_lookup
private

◆ max_size

template<typename Key , typename Value , typename Compare = std::less<Key>>
size_t LRUcache< Key, Value, Compare >::max_size
private

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