MostRecentlyUsedCache< TKey, TValue > Class Template Reference

This file is part of SpringLobby, Copyright (C) 2007-2011. More...

#include <mru_cache.h>

Collaboration diagram for MostRecentlyUsedCache< TKey, TValue >:
Collaboration graph
[legend]

Public Member Functions

 MostRecentlyUsedCache (int max_size, const wxString &name=_T(""))
 name parameter might be used to identify stats in dgb output
 ~MostRecentlyUsedCache ()
void Add (const TKey &name, const TValue &img)
bool TryGet (const TKey &name, TValue &img)
void Clear ()

Private Types

typedef std::pair< TKey, TValue > CacheItem
typedef std::list< CacheItemCacheItemList
typedef std::map< TKey,
typename
CacheItemList::iterator > 
IteratorMap

Private Attributes

wxCriticalSection m_lock
CacheItemList m_items
IteratorMap m_iterator_map
int m_size
const int m_max_size
int m_cache_hits
int m_cache_misses
const wxString m_name

Detailed Description

template<typename TKey, typename TValue>
class MostRecentlyUsedCache< TKey, TValue >

This file is part of SpringLobby, Copyright (C) 2007-2011.

SpringLobby is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

SpringLobby is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with SpringLobby. If not, see <http://www.gnu.org/licenses/>. Thread safe MRU cache (works like a std::map but has maximum size)

Definition at line 33 of file mru_cache.h.


Member Typedef Documentation

template<typename TKey, typename TValue>
typedef std::pair<TKey, TValue> MostRecentlyUsedCache< TKey, TValue >::CacheItem [private]

Definition at line 88 of file mru_cache.h.

template<typename TKey, typename TValue>
typedef std::list<CacheItem> MostRecentlyUsedCache< TKey, TValue >::CacheItemList [private]

Definition at line 89 of file mru_cache.h.

template<typename TKey, typename TValue>
typedef std::map<TKey, typename CacheItemList::iterator> MostRecentlyUsedCache< TKey, TValue >::IteratorMap [private]

Definition at line 90 of file mru_cache.h.


Constructor & Destructor Documentation

template<typename TKey, typename TValue>
MostRecentlyUsedCache< TKey, TValue >::MostRecentlyUsedCache ( int  max_size,
const wxString name = _T("") 
) [inline]

name parameter might be used to identify stats in dgb output

Definition at line 37 of file mru_cache.h.

template<typename TKey, typename TValue>
MostRecentlyUsedCache< TKey, TValue >::~MostRecentlyUsedCache (  )  [inline]

Definition at line 42 of file mru_cache.h.


Member Function Documentation

template<typename TKey, typename TValue>
void MostRecentlyUsedCache< TKey, TValue >::Add ( const TKey &  name,
const TValue &  img 
) [inline]

Definition at line 48 of file mru_cache.h.

template<typename TKey, typename TValue>
void MostRecentlyUsedCache< TKey, TValue >::Clear (  )  [inline]

Definition at line 79 of file mru_cache.h.

template<typename TKey, typename TValue>
bool MostRecentlyUsedCache< TKey, TValue >::TryGet ( const TKey &  name,
TValue &  img 
) [inline]

Definition at line 61 of file mru_cache.h.


Field Documentation

template<typename TKey, typename TValue>
int MostRecentlyUsedCache< TKey, TValue >::m_cache_hits [private]

Definition at line 97 of file mru_cache.h.

template<typename TKey, typename TValue>
int MostRecentlyUsedCache< TKey, TValue >::m_cache_misses [private]

Definition at line 98 of file mru_cache.h.

template<typename TKey, typename TValue>
CacheItemList MostRecentlyUsedCache< TKey, TValue >::m_items [private]

Definition at line 93 of file mru_cache.h.

template<typename TKey, typename TValue>
IteratorMap MostRecentlyUsedCache< TKey, TValue >::m_iterator_map [private]

Definition at line 94 of file mru_cache.h.

template<typename TKey, typename TValue>
wxCriticalSection MostRecentlyUsedCache< TKey, TValue >::m_lock [mutable, private]

Definition at line 92 of file mru_cache.h.

template<typename TKey, typename TValue>
const int MostRecentlyUsedCache< TKey, TValue >::m_max_size [private]

Definition at line 96 of file mru_cache.h.

template<typename TKey, typename TValue>
const wxString MostRecentlyUsedCache< TKey, TValue >::m_name [private]

Definition at line 99 of file mru_cache.h.

template<typename TKey, typename TValue>
int MostRecentlyUsedCache< TKey, TValue >::m_size [private]

Definition at line 95 of file mru_cache.h.


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

Generated on Thu Dec 29 00:11:47 2011 for SpringLobby by doxygen 1.6.3