FX::QDictBase< keytype, type > Class Template Reference

#include <qdictbase.h>

Inheritance diagram for FX::QDictBase< keytype, type >:

Inheritance graph
[legend]

List of all members.


Detailed Description

template<class keytype, class type>
class FX::QDictBase< keytype, type >

Base implementation class for all QTL dictionary classes.

Some notes on observed behaviour deduced by real-world testing:


Public Types

enum  { HasSlowKeyCompare }
typedef keytype KeyType
typedef type ItemType

Public Member Functions

 QDictBase (uint _size, bool wantAutoDel=false)
 QDictBase (const QDictBase< keytype, type > &o)
QDictBase< keytype, type > & operator= (const QDictBase< keytype, type > &o)
bool autoDelete () const
void setAutoDelete (bool a)
uint count () const
bool isEmpty () const
uint size () const
void clear ()
void append (const QDictBase< keytype, type > &o)
QDictBase< keytype, type > & operator+= (const QDictBase< keytype, type > &o)
void resize (uint newsize)
void safeResize (uint newsize) throw ()
void spread (float *full, float *slotsspread, float *avrgkeysperslot, float *spread) const
void statistics () const
FXint dictionaryBias () const throw ()

Protected Types

typedef std::map< keytype,
hashitemlist > 
keyitemlist
typedef keyitemlist::value_type keyitem

Protected Member Functions

keyitem * findKey (FXuint h, const keytype &k)
const keyitem * findKey (FXuint h, const keytype &k) const
void insert (FXuint h, const keytype &k, type *d)
void replace (FXuint h, const keytype &k, type *d)
bool remove (FXuint h, const keytype &k)
type * take (FXuint h, const keytype &k)
type * find (FXuint h, const keytype &k) const
virtual void deleteItem (type *d)=0

Friends

class QDictBaseIterator< keytype, type >

Member Typedef Documentation

template<class keytype, class type>
typedef keytype FX::QDictBase< keytype, type >::KeyType

The type of the key.

template<class keytype, class type>
typedef type FX::QDictBase< keytype, type >::ItemType

The type of the container's item.


Member Function Documentation

template<class keytype, class type>
bool FX::QDictBase< keytype, type >::autoDelete (  )  const [inline]

Returns if auto-deletion is enabled.

template<class keytype, class type>
void FX::QDictBase< keytype, type >::setAutoDelete ( bool  a  )  [inline]

Sets if auto-deletion is enabled.

template<class keytype, class type>
uint FX::QDictBase< keytype, type >::count (  )  const [inline]

Returns the number of items in the list.

template<class keytype, class type>
bool FX::QDictBase< keytype, type >::isEmpty (  )  const [inline]

Returns true if the list is empty.

template<class keytype, class type>
uint FX::QDictBase< keytype, type >::size (  )  const [inline]

Returns the size of the hash table.

template<class keytype, class type>
void FX::QDictBase< keytype, type >::clear (  )  [inline]

Clears the list of items, auto-deleting if enabled.

template<class keytype, class type>
void FX::QDictBase< keytype, type >::append ( const QDictBase< keytype, type > &  o  )  [inline]

Appends the contents of another dictionary.

Referenced by FX::QDictBase< FX::FXString, type >::operator+=().

template<class keytype, class type>
QDictBase<keytype, type>& FX::QDictBase< keytype, type >::operator+= ( const QDictBase< keytype, type > &  o  )  [inline]

template<class keytype, class type>
void FX::QDictBase< keytype, type >::resize ( uint  newsize  )  [inline]

Resizes the hash table (see QDICTDYNRESIZE()). Invalidates all iterators.

template<class keytype, class type>
void FX::QDictBase< keytype, type >::safeResize ( uint  newsize  )  throw () [inline]

Resizes the hash table with no threat of memory full exceptions. Invalidates all iterators.

template<class keytype, class type>
void FX::QDictBase< keytype, type >::spread ( float *  full,
float *  slotsspread,
float *  avrgkeysperslot,
float *  spread 
) const [inline]

Returns statistics useful for dynamic balancing of the table. If full exceeds 100%, then there are more items than slots and the table is no longer performing at maximum efficiency. If slotsspread is less than 50% then the hash function is broken. Ideally for performance purposes avrgkeysperslot should be near 1.0 and finally spread is slotsspread divided by avrgskeysperslot which is an overall indication of spread and thus efficiency of the table. Of course maximum efficiency is pointless for very large sets of data where avrgkeysperslot could be as much as eight - but slotsspread should always be near 100%

Referenced by FX::QDictBase< FX::FXString, type >::statistics().

template<class keytype, class type>
void FX::QDictBase< keytype, type >::statistics (  )  const [inline]

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

Reimplemented in FX::FXLRUCache< FX::QIntDict< type > >, and FX::FXLRUCache< FX::QDict< type > >.

template<class keytype, class type>
FXint FX::QDictBase< keytype, type >::dictionaryBias (  )  const throw () [inline]

Returns a number indicating how biased between lookups and insert/removals the usage of this dictionary has been so far. Is negative for more insert/removals than lookups and positive for the opposite.


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:33 2008 for TnFOX by doxygen v1.5.6