Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::LRUCache< K, KComp, V > Struct Template Reference

Generic LRU cache implementation. More...

#include <mitsuba/core/lrucache.h>

+ Inheritance diagram for mitsuba::LRUCache< K, KComp, V >:

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
 
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 ClassgetClass () 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 Classm_theClass
 Pointer to the object's class descriptor. More...
 

Detailed Description

template<typename K, typename KComp, typename V>
struct mitsuba::LRUCache< K, KComp, V >

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.nosp@m.y@ti.nosp@m.mday..nosp@m.com
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.
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.
Template Parameters
KKey data type
KCompKey comparator
VValue data type

Member Typedef Documentation

template<typename K , typename KComp , typename V >
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
template<typename K , typename KComp , typename V >
typedef int mitsuba::LRUCache< K, KComp, V >::dummy_type

Constructor & Destructor Documentation

template<typename K , typename KComp , typename V >
mitsuba::LRUCache< K, KComp, V >::LRUCache ( )
inline
template<typename K , typename KComp , typename V >
mitsuba::LRUCache< K, KComp, V >::LRUCache ( size_t  capacity,
const boost::function< V(const K &)> &  generatorFunction,
const boost::function< void(const V &)> &  cleanupFunction = NULL 
)
inline
template<typename K , typename KComp , typename V >
virtual mitsuba::LRUCache< K, KComp, V >::~LRUCache ( )
inlinevirtual

Member Function Documentation

template<typename K , typename KComp , typename V >
V mitsuba::LRUCache< K, KComp, V >::get ( const K &  k,
bool hit 
)
inline
template<typename K , typename KComp , typename V >
template<typename IT >
void mitsuba::LRUCache< K, KComp, V >::get_keys ( IT  dst) const
inline
template<typename K , typename KComp , typename V >
void mitsuba::LRUCache< K, KComp, V >::insert ( const K &  k,
const V &  v 
)
inlineprotected
template<typename K , typename KComp , typename V >
bool mitsuba::LRUCache< K, KComp, V >::isFull ( ) const
inline

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