CCF
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
LRU< K, V > Class Template Reference

#include <lru.h>

Public Types

using Entry = std::pair< const K, V >
 
using List = std::list< Entry >
 
using Map = std::map< K, typename List::iterator >
 
using Iterator = typename List::iterator
 
using ConstIterator = typename List::const_iterator
 

Public Member Functions

 LRU (size_t max_size)
 
size_t size () const
 
void set_max_size (size_t ms)
 
size_t get_max_size () const
 
Iterator begin ()
 
Iterator end ()
 
ConstIterator begin () const
 
ConstIterator end () const
 
Iterator find (const K &k)
 
bool contains (const K &k) const
 
void promote (const Iterator &list_it)
 
Iterator insert (const K &k, V &&v)
 
V & operator[] (const K &k)
 
void clear ()
 

Detailed Description

template<typename K, typename V>
class LRU< K, V >

A basic LRU implementation, written for the specific purpose of managing a cache of Verifiers in CCF. If using for any other purpose, check carefully that this still does what you want!

The search methods (begin, end, find, contains) do not count as access and do not alter the recently used order. Only insert(), promote(), and operator[] modify the order.

Member Typedef Documentation

◆ ConstIterator

template<typename K , typename V >
using LRU< K, V >::ConstIterator = typename List::const_iterator

◆ Entry

template<typename K , typename V >
using LRU< K, V >::Entry = std::pair<const K, V>

◆ Iterator

template<typename K , typename V >
using LRU< K, V >::Iterator = typename List::iterator

◆ List

template<typename K , typename V >
using LRU< K, V >::List = std::list<Entry>

◆ Map

template<typename K , typename V >
using LRU< K, V >::Map = std::map<K, typename List::iterator>

Constructor & Destructor Documentation

◆ LRU()

template<typename K , typename V >
LRU< K, V >::LRU ( size_t  max_size)
inline

Member Function Documentation

◆ begin() [1/2]

template<typename K , typename V >
Iterator LRU< K, V >::begin ( )
inline

◆ begin() [2/2]

template<typename K , typename V >
ConstIterator LRU< K, V >::begin ( ) const
inline

◆ clear()

template<typename K , typename V >
void LRU< K, V >::clear ( )
inline

◆ contains()

template<typename K , typename V >
bool LRU< K, V >::contains ( const K &  k) const
inline

◆ end() [1/2]

template<typename K , typename V >
Iterator LRU< K, V >::end ( )
inline

◆ end() [2/2]

template<typename K , typename V >
ConstIterator LRU< K, V >::end ( ) const
inline

◆ find()

template<typename K , typename V >
Iterator LRU< K, V >::find ( const K &  k)
inline

◆ get_max_size()

template<typename K , typename V >
size_t LRU< K, V >::get_max_size ( ) const
inline

◆ insert()

template<typename K , typename V >
Iterator LRU< K, V >::insert ( const K &  k,
V &&  v 
)
inline

◆ operator[]()

template<typename K , typename V >
V & LRU< K, V >::operator[] ( const K &  k)
inline

◆ promote()

template<typename K , typename V >
void LRU< K, V >::promote ( const Iterator list_it)
inline

◆ set_max_size()

template<typename K , typename V >
void LRU< K, V >::set_max_size ( size_t  ms)
inline

◆ size()

template<typename K , typename V >
size_t LRU< K, V >::size ( ) const
inline

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