libmoost
|
an lru is a collection of keys and values, with a max size. Once the max size is reached, further inserted elements push out least recently used elements. More...
#include <lru.hpp>
Public Types | |
typedef lru_t::value_type | value_type |
typedef lru_t::value_type::first_type | key_type |
typedef lru_t::value_type::second_type | mapped_type |
typedef lru_t::iterator | iterator |
typedef lru_t::const_iterator | const_iterator |
typedef lru_t::reference | reference |
typedef lru_t::const_reference | const_reference |
Public Member Functions | |
lru (size_t max_size=std::numeric_limits< size_t >::max()) | |
Constructs an lru. | |
void | set_deleted_key (const key_type &deleted_key) |
bool | get (const key_type &key, mapped_type &value, bool bbump=true) |
Gets a value given a key. Returns false if not in lru. | |
void | put (const key_type &key, const mapped_type &value, evict_func_t evict_func=evict_func_t()) |
void | erase (const key_type &key) |
erase an element from the lru | |
bool | peek (const key_type &key, mapped_type &value) |
gets a value from the lru but doesn't bump it | |
bool | bump (const key_type &key) |
bool | exists (const key_type &key) const |
const_iterator | find (const key_type &key) const |
iterator | find (const key_type &key) |
reference | front () |
const_reference | front () const |
reference | back () |
const_reference | back () const |
std::pair< iterator, bool > | insert (const key_type &key, const mapped_type &value, evict_func_t evict_func=evict_func_t()) |
bool | bump (iterator itr) |
void | erase (iterator it) |
mapped_type const & | operator[] (key_type const &key) const |
mapped_type & | operator[] (key_type const &key) |
void | clear () |
Clear the lru. | |
void | purge () |
Purge the lru. | |
size_t | size () const |
Gets the number of elements in the lru. | |
bool | empty () const |
Returns true if empty. | |
size_t | max_size () const |
Gets the max number of elements in the lru. | |
iterator | begin () |
Gets the beginning of the lru. | |
const_iterator | begin () const |
Gets the beginning of the lru. | |
iterator | end () |
Gets the end of the lru. | |
const_iterator | end () const |
Gets the end of the lru. | |
Private Types | |
typedef std::list< std::pair < Key, Data > > | lru_t |
typedef google::sparse_hash_map < key_type, iterator, HashFcn > | hm_key_data |
typedef boost::function< bool(key_type, const mapped_type &value)> | evict_func_t |
Private Attributes | |
lru_t | m_lru |
hm_key_data | m_key_data |
size_t | m_max_size |
an lru is a collection of keys and values, with a max size. Once the max size is reached, further inserted elements push out least recently used elements.
typedef lru_t::const_iterator moost::container::lru< Key, Data, HashFcn >::const_iterator |
typedef lru_t::const_reference moost::container::lru< Key, Data, HashFcn >::const_reference |
typedef boost::function<bool(key_type, const mapped_type & value)> moost::container::lru< Key, Data, HashFcn >::evict_func_t [private] |
typedef google::sparse_hash_map< key_type, iterator, HashFcn > moost::container::lru< Key, Data, HashFcn >::hm_key_data [private] |
typedef lru_t::iterator moost::container::lru< Key, Data, HashFcn >::iterator |
typedef lru_t::value_type::first_type moost::container::lru< Key, Data, HashFcn >::key_type |
typedef std::list< std::pair< Key, Data > > moost::container::lru< Key, Data, HashFcn >::lru_t [private] |
typedef lru_t::value_type::second_type moost::container::lru< Key, Data, HashFcn >::mapped_type |
typedef lru_t::reference moost::container::lru< Key, Data, HashFcn >::reference |
typedef lru_t::value_type moost::container::lru< Key, Data, HashFcn >::value_type |
moost::container::lru< Key, Data, HashFcn >::lru | ( | size_t | max_size = std::numeric_limits<size_t>::max() | ) | [inline] |
reference moost::container::lru< Key, Data, HashFcn >::back | ( | ) | [inline] |
const_reference moost::container::lru< Key, Data, HashFcn >::back | ( | ) | const [inline] |
iterator moost::container::lru< Key, Data, HashFcn >::begin | ( | ) | [inline] |
const_iterator moost::container::lru< Key, Data, HashFcn >::begin | ( | ) | const [inline] |
bool moost::container::lru< Key, Data, HashFcn >::bump | ( | const key_type & | key | ) | [inline] |
bool moost::container::lru< Key, Data, HashFcn >::bump | ( | iterator | itr | ) | [inline] |
void moost::container::lru< Key, Data, HashFcn >::clear | ( | ) | [inline] |
bool moost::container::lru< Key, Data, HashFcn >::empty | ( | ) | const [inline] |
iterator moost::container::lru< Key, Data, HashFcn >::end | ( | ) | [inline] |
const_iterator moost::container::lru< Key, Data, HashFcn >::end | ( | ) | const [inline] |
void moost::container::lru< Key, Data, HashFcn >::erase | ( | const key_type & | key | ) | [inline] |
void moost::container::lru< Key, Data, HashFcn >::erase | ( | iterator | it | ) | [inline] |
bool moost::container::lru< Key, Data, HashFcn >::exists | ( | const key_type & | key | ) | const [inline] |
const_iterator moost::container::lru< Key, Data, HashFcn >::find | ( | const key_type & | key | ) | const [inline] |
iterator moost::container::lru< Key, Data, HashFcn >::find | ( | const key_type & | key | ) | [inline] |
reference moost::container::lru< Key, Data, HashFcn >::front | ( | ) | [inline] |
const_reference moost::container::lru< Key, Data, HashFcn >::front | ( | ) | const [inline] |
bool moost::container::lru< Key, Data, HashFcn >::get | ( | const key_type & | key, |
mapped_type & | value, | ||
bool | bbump = true |
||
) | [inline] |
std::pair<iterator, bool> moost::container::lru< Key, Data, HashFcn >::insert | ( | const key_type & | key, |
const mapped_type & | value, | ||
evict_func_t | evict_func = evict_func_t() |
||
) | [inline] |
size_t moost::container::lru< Key, Data, HashFcn >::max_size | ( | ) | const [inline] |
mapped_type const& moost::container::lru< Key, Data, HashFcn >::operator[] | ( | key_type const & | key | ) | const [inline] |
mapped_type& moost::container::lru< Key, Data, HashFcn >::operator[] | ( | key_type const & | key | ) | [inline] |
bool moost::container::lru< Key, Data, HashFcn >::peek | ( | const key_type & | key, |
mapped_type & | value | ||
) | [inline] |
void moost::container::lru< Key, Data, HashFcn >::purge | ( | ) | [inline] |
void moost::container::lru< Key, Data, HashFcn >::put | ( | const key_type & | key, |
const mapped_type & | value, | ||
evict_func_t | evict_func = evict_func_t() |
||
) | [inline] |
void moost::container::lru< Key, Data, HashFcn >::set_deleted_key | ( | const key_type & | deleted_key | ) | [inline] |
size_t moost::container::lru< Key, Data, HashFcn >::size | ( | ) | const [inline] |
hm_key_data moost::container::lru< Key, Data, HashFcn >::m_key_data [private] |
lru_t moost::container::lru< Key, Data, HashFcn >::m_lru [private] |
size_t moost::container::lru< Key, Data, HashFcn >::m_max_size [private] |