dune-common 2.9.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
Dune::lru< Key, Tp, Traits > Class Template Reference

LRU Cache Container. More...

#include <dune/common/lru.hh>

Public Types

typedef Traits::key_type key_type
 
typedef allocator::value_type value_type
 
using pointer = typename allocator::value_type *
 
using const_pointer = typename allocator::value_type const *
 
using const_reference = typename allocator::value_type const &
 
using reference = typename allocator::value_type &
 
typedef allocator::size_type size_type
 
typedef list_type::iterator iterator
 
typedef list_type::const_iterator const_iterator
 

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.
 
const_iterator find (const key_type &key) const
 Finds the element whose key is k.
 
reference insert (const key_type &key, const_reference data)
 Insert a value into the container.
 
reference insert (const key_type &key)
 mark data associated with key as most recent
 
reference touch (const key_type &key)
 mark data associated with key as most recent
 
size_type size () const
 Retrieve number of entries in the container.
 
void resize (size_type new_size)
 ensure a maximum size of the container
 
void clear ()
 

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 Typedef Documentation

◆ const_iterator

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
typedef list_type::const_iterator Dune::lru< Key, Tp, Traits >::const_iterator

◆ const_pointer

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
using Dune::lru< Key, Tp, Traits >::const_pointer = typename allocator::value_type const*

◆ const_reference

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
using Dune::lru< Key, Tp, Traits >::const_reference = typename allocator::value_type const&

◆ iterator

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
typedef list_type::iterator Dune::lru< Key, Tp, Traits >::iterator

◆ key_type

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
typedef Traits::key_type Dune::lru< Key, Tp, Traits >::key_type

◆ pointer

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
using Dune::lru< Key, Tp, Traits >::pointer = typename allocator::value_type*

◆ reference

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
using Dune::lru< Key, Tp, Traits >::reference = typename allocator::value_type&

◆ size_type

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
typedef allocator::size_type Dune::lru< Key, Tp, Traits >::size_type

◆ value_type

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
typedef allocator::value_type Dune::lru< Key, Tp, Traits >::value_type

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.

◆ clear()

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
void Dune::lru< Key, Tp, Traits >::clear ( )
inline

◆ 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

◆ 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

◆ pop_back()

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
void Dune::lru< Key, Tp, Traits >::pop_back ( )
inline

Removes the last element.

◆ pop_front()

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
void Dune::lru< Key, Tp, Traits >::pop_front ( )
inline

Removes the first element.

◆ 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.

◆ size()

template<typename Key , typename Tp , typename Traits = _lru_default_traits<Key, Tp>>
size_type Dune::lru< Key, Tp, Traits >::size ( ) const
inline

Retrieve number of entries in the container.

◆ 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

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