IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
IMP::LRUCache< Generator, Checker > Class Template Reference

Implement a simple least recently used cache. More...

#include <IMP/cache.h>

Detailed Description

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
class IMP::LRUCache< Generator, Checker >

Implement a simple least recently used cache.

As with the Memoizer, it is parameterized by a generator that is used to generate values if they are not in the cache.

The Generator should have a method:

  • Generator::operator()(Key, Cache);

Definition at line 254 of file cache.h.

Public Types

typedef OrderIterator ContentIterator
typedef Generator::argument_type Key
typedef Generator::result_type Value

Public Member Functions

 LRUCache (const Generator &gen, unsigned int size, const Checker checker=Checker())
Generator & access_generator ()
ContentIterator contents_begin () const
ContentIterator contents_end () const
Value get (const Key &k) const
const Generator & get_generator () const
double get_hit_rate () const
Vector< Key > get_keys () const
void insert (Key k, Value v)
unsigned int size () const

Member Typedef Documentation

◆ ContentIterator

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
typedef OrderIterator IMP::LRUCache< Generator, Checker >::ContentIterator

Definition at line 334 of file cache.h.

◆ Key

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
typedef Generator::argument_type IMP::LRUCache< Generator, Checker >::Key

Definition at line 257 of file cache.h.

◆ Value

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
typedef Generator::result_type IMP::LRUCache< Generator, Checker >::Value

Definition at line 256 of file cache.h.

Constructor & Destructor Documentation

◆ LRUCache()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
IMP::LRUCache< Generator, Checker >::LRUCache ( const Generator & gen,
unsigned int size,
const Checker checker = Checker() )

Definition at line 291 of file cache.h.

Member Function Documentation

◆ access_generator()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
Generator & IMP::LRUCache< Generator, Checker >::access_generator ( )

Definition at line 349 of file cache.h.

◆ contents_begin()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
ContentIterator IMP::LRUCache< Generator, Checker >::contents_begin ( ) const

Definition at line 335 of file cache.h.

◆ contents_end()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
ContentIterator IMP::LRUCache< Generator, Checker >::contents_end ( ) const

Definition at line 338 of file cache.h.

◆ get()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
Value IMP::LRUCache< Generator, Checker >::get ( const Key & k) const

Definition at line 298 of file cache.h.

◆ get_generator()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
const Generator & IMP::LRUCache< Generator, Checker >::get_generator ( ) const

Definition at line 350 of file cache.h.

◆ get_hit_rate()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
double IMP::LRUCache< Generator, Checker >::get_hit_rate ( ) const

Definition at line 323 of file cache.h.

◆ get_keys()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
Vector< Key > IMP::LRUCache< Generator, Checker >::get_keys ( ) const

Definition at line 326 of file cache.h.

◆ insert()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
void IMP::LRUCache< Generator, Checker >::insert ( Key k,
Value v )

Definition at line 339 of file cache.h.

◆ size()

template<class Generator, class Checker = std::equal_to<typename Generator::result_type>>
unsigned int IMP::LRUCache< Generator, Checker >::size ( ) const

Definition at line 348 of file cache.h.


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