Dune Core Modules (2.6.0)

Dune::lru< _Key, _Tp, _Traits > Class Template Reference

LRU Cache Container. More...

#include <dune/common/lru.hh>

Public Member Functions

reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back (int i) const
 
void pop_front ()
 Removes the first element.
 
void pop_back ()
 Removes the last element.
 
iterator find (const key_type &key)
 Finds the element whose key is k. More...
 
const_iterator find (const key_type &key) const
 Finds the element whose key is k. More...
 
reference insert (const key_type &key, const_reference data)
 Insert a value into the container. More...
 
reference insert (const key_type &key)
 mark data associated with key as most recent More...
 
reference touch (const key_type &key)
 mark data associated with key as most recent More...
 
size_type size () const
 Retrieve number of entries in the container.
 
void resize (size_type new_size)
 ensure a maximum size of the container More...
 

Detailed Description

template<typename _Key, typename _Tp, typename _Traits = _lru_default_traits<_Key, _Tp>>
class Dune::lru< _Key, _Tp, _Traits >

LRU Cache Container.

Implementation of an LRU (least recently used) cache container. This implementation follows the approach presented in http://aim.adc.rmit.edu.au/phd/sgreuter/papers/graphite2003.pdf

Member Function Documentation

◆ back() [1/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
reference Dune::lru< _Key, _Tp, _Traits >::back ( )
inline

Returns a read/write reference to the data of the least recently used entry.

◆ back() [2/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
const_reference Dune::lru< _Key, _Tp, _Traits >::back ( int  i) const
inline

Returns a read-only (constant) reference to the data of the least recently used entry.

References DUNE_UNUSED_PARAMETER.

◆ find() [1/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
iterator Dune::lru< _Key, _Tp, _Traits >::find ( const key_type &  key)
inline

Finds the element whose key is k.

Returns
iterator

◆ find() [2/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
const_iterator Dune::lru< _Key, _Tp, _Traits >::find ( const key_type &  key) const
inline

Finds the element whose key is k.

Returns
const_iterator

◆ front() [1/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
reference Dune::lru< _Key, _Tp, _Traits >::front ( )
inline

Returns a read/write reference to the data of the most recently used entry.

◆ front() [2/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
const_reference Dune::lru< _Key, _Tp, _Traits >::front ( ) const
inline

Returns a read-only (constant) reference to the data of the most recently used entry.

◆ insert() [1/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
reference Dune::lru< _Key, _Tp, _Traits >::insert ( const key_type &  key)
inline

mark data associated with key as most recent

Returns
reference of stored data

References Dune::lru< _Key, _Tp, _Traits >::touch().

◆ insert() [2/2]

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
reference Dune::lru< _Key, _Tp, _Traits >::insert ( const key_type &  key,
const_reference  data 
)
inline

Insert a value into the container.

Stores value under key and marks it as most recent. If this key is already present, the associated data is replaced.

Parameters
keyassociated with data
datato store
Returns
reference of stored data

◆ resize()

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
void Dune::lru< _Key, _Tp, _Traits >::resize ( size_type  new_size)
inline

ensure a maximum size of the container

If new_size is smaller than size the oldest elements are dropped. Otherwise nothing happens.

References Dune::lru< _Key, _Tp, _Traits >::pop_back(), and Dune::lru< _Key, _Tp, _Traits >::size().

◆ touch()

template<typename _Key , typename _Tp , typename _Traits = _lru_default_traits<_Key, _Tp>>
reference Dune::lru< _Key, _Tp, _Traits >::touch ( const key_type &  key)
inline

mark data associated with key as most recent

Returns
reference of stored data

References DUNE_THROW.

Referenced by Dune::lru< _Key, _Tp, _Traits >::insert().


The documentation for this class was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)