Generic LRU cache implementation. More...
#include <mitsuba/core/lrucache.h>
Public Types | |
typedef int | dummy_type |
typedef boost::bimaps::bimap < boost::bimaps::set_of< K, KComp > , boost::bimaps::list_of < dummy_type > , boost::bimaps::with_info< V > > | cache_type |
Public Member Functions | |
LRUCache () | |
LRUCache (size_t capacity, const boost::function< V(const K &)> &generatorFunction, const boost::function< void(const V &)> &cleanupFunction=NULL) | |
virtual | ~LRUCache () |
bool | isFull () const |
V | get (const K &k, bool &hit) |
template<typename IT > | |
void | get_keys (IT dst) const |
Public Member Functions inherited from Object | |
Object () | |
Construct a new object. More... | |
int | getRefCount () const |
Return the current reference count. More... | |
void | incRef () const |
Increase the reference count of the object by one. More... | |
void | decRef (bool autoDeallocate=true) const |
Decrease the reference count of the object and possibly deallocate it. More... | |
virtual const Class * | getClass () const |
Retrieve this object's class. More... | |
virtual std::string | toString () const |
Return a human-readable string representation of the object's contents. More... | |
Protected Member Functions | |
void | insert (const K &k, const V &v) |
Protected Member Functions inherited from Object | |
virtual | ~Object () |
Virtual private deconstructor. (Will only be called by ref) More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from Object | |
static void | staticInitialization () |
Initializes the built-in reference count debugger (if enabled) More... | |
static void | staticShutdown () |
Free the memory taken by staticInitialization() More... | |
Static Public Attributes inherited from Object | |
static Class * | m_theClass |
Pointer to the object's class descriptor. More... | |
Generic LRU cache implementation.
Based on the bimap implementation by Tim Day (http://timday.bitbucket.org/lru.html).
This cache does not support multithreading out of the box – it will need to be protected using some form of locking mechanism.
The original code is under the following license:
Copyright (c) 2010, Tim Day timda Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. y@ti mday. com
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
K | Key data type |
KComp | Key comparator |
V | Value data type |
typedef boost::bimaps::bimap< boost::bimaps::set_of<K, KComp>, boost::bimaps::list_of<dummy_type>, boost::bimaps::with_info<V> > mitsuba::LRUCache< K, KComp, V >::cache_type |
typedef int mitsuba::LRUCache< K, KComp, V >::dummy_type |
|
inline |
|
inline |
|
inlinevirtual |
|
inline |
|
inline |
|
inlineprotected |
|
inline |