#include <qcache.h>
Public Types | |
typedef dictbase::KeyType | KeyType |
typedef dictbase::ItemType | FundamentalDictType |
Public Member Functions | |
QCache (FXuint maxCost=100, FXuint size=13, bool caseSensitive=true, bool autodel=false) | |
void | setAutoDelete (bool a) |
bool | dynamic () const throw () |
void | setDynamic (bool v) const throw () |
FXuint | maxCost () const throw () |
void | setMaxCost (FXuint newmax) |
FXuint | totalCost () const throw () |
void | cacheStats (float *hitrate, float *churn) const throw () |
void | statistics () const |
bool | insert (KeyTypeAsParam k, TypeAsParam d, FXint itemcost=1) |
bool | remove (KeyTypeAsParam k) |
TypeAsReturn | take (KeyTypeAsParam k) |
TypeAsReturn | find (KeyTypeAsParam k, bool tofront=true) const |
TypeAsReturn | operator[] (KeyTypeAsParam k) const |
Protected Types | |
typedef FundamentalDictType * | DictType |
typedef Generic::select < Generic::sameType< type, Generic::NullType >::value, DictType, type >::value | Type |
typedef Generic::TraitsBasic < Type > | TypeTraits |
typedef Generic::TraitsBasic < KeyType >::asROParam | KeyTypeAsParam |
typedef TypeTraits::asROParam | TypeAsParam |
typedef Generic::leastIndir < Type >::value * | TypeAsReturn |
typedef FXLRUCacheImpl::getPtr < Type, TypeAsParam, TypeTraits::isValue > | CacheItemBase |
Protected Member Functions | |
virtual void | purgeLFU () |
virtual void | deleteItem (DictType d) |
Protected Attributes | |
FXuint | topmax |
FXuint | maximum |
FXuint | cost |
bool | amDynamic |
std::list< CacheItem > | cache |
struct FX::FXLRUCache::stats_t | stats |
FX::QCache< type >::QCache | ( | FXuint | maxCost = 100 , |
|
FXuint | size = 13 , |
|||
bool | caseSensitive = true , |
|||
bool | autodel = false | |||
) | [inline] |
Constructs an instance with maximum cost maxCost and dictionary size size with optional case sensitivity.
virtual void FX::FXLRUCache< dictbase, type >::purgeLFU | ( | ) | [inline, protected, virtual, inherited] |
Called when totalCost() exceeds maxCost() to purge the least recently used items. The default implementation works on the basis of the least recently looked up via find(), however this is virtual so you can override it with a more intelligent mechanism
bool FX::FXLRUCache< dictbase, type >::dynamic | ( | ) | const throw () [inline, inherited] |
Returns if this cache adjusts itself dynamically to memory full.
void FX::FXLRUCache< dictbase, type >::setDynamic | ( | bool | v | ) | const throw () [inline, inherited] |
Sets if this cache adjusts itself dynamically to memory full.
FXuint FX::FXLRUCache< dictbase, type >::maxCost | ( | ) | const throw () [inline, inherited] |
Returns the maximum cost permitted by the cache.
void FX::FXLRUCache< dictbase, type >::setMaxCost | ( | FXuint | newmax | ) | [inline, inherited] |
Sets the maximum cost permitted. Disposes of items immediately if the new cost warrants it.
FXuint FX::FXLRUCache< dictbase, type >::totalCost | ( | ) | const throw () [inline, inherited] |
Returns the total cost of the cache's current contents.
void FX::FXLRUCache< dictbase, type >::cacheStats | ( | float * | hitrate, | |
float * | churn | |||
) | const throw () [inline, inherited] |
Returns operating statistics about the cache. hitrate is a percentage of hits versus total lookups and churn is a percentage of items flushed versus total lookups.
Referenced by FX::FXLRUCache< FX::QDict< type > >::statistics().
void FX::FXLRUCache< dictbase, type >::statistics | ( | ) | const [inline, inherited] |
Prints some statistics about the hash table (only debug builds).
bool FX::FXLRUCache< dictbase, type >::insert | ( | KeyTypeAsParam | k, | |
TypeAsParam | d, | |||
FXint | itemcost = 1 | |||
) | [inline, inherited] |
bool FX::FXLRUCache< dictbase, type >::remove | ( | KeyTypeAsParam | k | ) | [inline, inherited] |
Removes the item associated with key k, deleting if auto-deletion is enabled.
TypeAsReturn FX::FXLRUCache< dictbase, type >::take | ( | KeyTypeAsParam | k | ) | [inline, inherited] |
Removes the item associated with key k, never deleting except when a value-based container (in which case, always returns zero)
TypeAsReturn FX::FXLRUCache< dictbase, type >::find | ( | KeyTypeAsParam | k, | |
bool | tofront = true | |||
) | const [inline, inherited] |
Finds the item associated with key k, returning zero if not found. Marks the item as most recently used if tofront is true.