dune-common 2.9.1
|
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 () |
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
Returns a read/write reference to the data of the least recently used entry.
|
inline |
Returns a read-only (constant) reference to the data of the least recently used entry.
Finds the element whose key is k.
|
inline |
Finds the element whose key is k.
Returns a read/write reference to the data of the most recently used entry.
|
inline |
Returns a read-only (constant) reference to the data of the most recently used entry.
mark data associated with key as most recent
|
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.
key | associated with data |
data | to store |
ensure a maximum size of the container
If new_size is smaller than size the oldest elements are dropped. Otherwise nothing happens.
Retrieve number of entries in the container.
mark data associated with key as most recent