FX::QIntCache< type > Class Template Reference

#include <qintcache.h>

Inheritance diagram for FX::QIntCache< type >:

Inheritance graph
[legend]

List of all members.


Detailed Description

template<class type>
class FX::QIntCache< type >

An implementation of Qt's QIntCache.

See also:
FX::QIntDict

Public Types

typedef dictbase::KeyType KeyType
typedef dictbase::ItemType FundamentalDictType

Public Member Functions

 QIntCache (FXuint maxCost=100, FXuint size=13, 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

Constructor & Destructor Documentation

template<class type>
FX::QIntCache< type >::QIntCache ( FXuint  maxCost = 100,
FXuint  size = 13,
bool  autodel = false 
) [inline]

Constructs an instance with maximum cost maxCost and dictionary size size.


Member Function Documentation

template<class dictbase, class type = Generic::NullType>
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

template<class dictbase, class type = Generic::NullType>
bool FX::FXLRUCache< dictbase, type >::dynamic (  )  const throw () [inline, inherited]

Returns if this cache adjusts itself dynamically to memory full.

template<class dictbase, class type = Generic::NullType>
void FX::FXLRUCache< dictbase, type >::setDynamic ( bool  v  )  const throw () [inline, inherited]

Sets if this cache adjusts itself dynamically to memory full.

template<class dictbase, class type = Generic::NullType>
FXuint FX::FXLRUCache< dictbase, type >::maxCost (  )  const throw () [inline, inherited]

Returns the maximum cost permitted by the cache.

template<class dictbase, class type = Generic::NullType>
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.

template<class dictbase, class type = Generic::NullType>
FXuint FX::FXLRUCache< dictbase, type >::totalCost (  )  const throw () [inline, inherited]

Returns the total cost of the cache's current contents.

template<class dictbase, class type = Generic::NullType>
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().

template<class dictbase, class type = Generic::NullType>
void FX::FXLRUCache< dictbase, type >::statistics (  )  const [inline, inherited]

Prints some statistics about the hash table (only debug builds).

template<class dictbase, class type = Generic::NullType>
bool FX::FXLRUCache< dictbase, type >::insert ( KeyTypeAsParam  k,
TypeAsParam  d,
FXint  itemcost = 1 
) [inline, inherited]

Returns:
False if item's cost is bigger than maxCost()
Inserts an item d into the cache under key k with cost itemcost. If the total cost of all the items in the cache exceed maxCost(), the least recently used item is flushed.

template<class dictbase, class type = Generic::NullType>
bool FX::FXLRUCache< dictbase, type >::remove ( KeyTypeAsParam  k  )  [inline, inherited]

Removes the item associated with key k, deleting if auto-deletion is enabled.

template<class dictbase, class type = Generic::NullType>
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)

template<class dictbase, class type = Generic::NullType>
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.


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

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:27:55 2008 for TnFOX by doxygen v1.5.6