#include <qptrdict.h>
Public Types | |
enum | { HasSlowKeyCompare } |
typedef keytype | KeyType |
typedef type | ItemType |
Public Member Functions | |
QPtrDict (int size=13, bool wantAutoDel=false) | |
void | insert (void *k, const type *d) |
void | replace (void *k, const type *d) |
bool | remove (void *k) |
type * | take (void *k) |
type * | find (void *k) const |
type * | operator[] (void *k) const |
template<> | |
void | deleteItem (void *) |
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 | |
virtual void | deleteItem (type *d) |
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 |
typedef keytype FX::QDictBase< keytype, type >::KeyType [inherited] |
The type of the key.
typedef type FX::QDictBase< keytype, type >::ItemType [inherited] |
The type of the container's item.
FX::QPtrDict< type >::QPtrDict | ( | int | size = 13 , |
|
bool | wantAutoDel = false | |||
) | [inline, explicit] |
Creates a hash table indexed by void pointers. Choose a prime for size.
void FX::QPtrDict< type >::insert | ( | void * | k, | |
const type * | d | |||
) | [inline] |
Inserts item d into the dictionary under key k.
void FX::QPtrDict< type >::replace | ( | void * | k, | |
const type * | d | |||
) | [inline] |
Replaces item d in the dictionary under key k.
bool FX::QPtrDict< type >::remove | ( | void * | k | ) | [inline] |
Deletes the most recently placed item in the dictionary under key k.
type* FX::QPtrDict< type >::take | ( | void * | k | ) | [inline] |
Removes the most recently placed item in the dictionary under key k without auto-deletion.
type* FX::QPtrDict< type >::find | ( | void * | k | ) | const [inline] |
Finds the most recently placed item in the dictionary under key k.
bool FX::QDictBase< keytype, type >::autoDelete | ( | ) | const [inline, inherited] |
Returns if auto-deletion is enabled.
void FX::QDictBase< keytype, type >::setAutoDelete | ( | bool | a | ) | [inline, inherited] |
Sets if auto-deletion is enabled.
uint FX::QDictBase< keytype, type >::count | ( | ) | const [inline, inherited] |
Returns the number of items in the list.
bool FX::QDictBase< keytype, type >::isEmpty | ( | ) | const [inline, inherited] |
Returns true if the list is empty.
uint FX::QDictBase< keytype, type >::size | ( | ) | const [inline, inherited] |
Returns the size of the hash table.
void FX::QDictBase< keytype, type >::clear | ( | ) | [inline, inherited] |
Clears the list of items, auto-deleting if enabled.
void FX::QDictBase< keytype, type >::append | ( | const QDictBase< keytype, type > & | o | ) | [inline, inherited] |
Appends the contents of another dictionary.
Referenced by FX::QDictBase< FX::FXString, type >::operator+=().
QDictBase<keytype, type>& FX::QDictBase< keytype, type >::operator+= | ( | const QDictBase< keytype, type > & | o | ) | [inline, inherited] |
void FX::QDictBase< keytype, type >::resize | ( | uint | newsize | ) | [inline, inherited] |
Resizes the hash table (see QDICTDYNRESIZE()). Invalidates all iterators.
void FX::QDictBase< keytype, type >::safeResize | ( | uint | newsize | ) | throw () [inline, inherited] |
Resizes the hash table with no threat of memory full exceptions. Invalidates all iterators.
void FX::QDictBase< keytype, type >::spread | ( | float * | full, | |
float * | slotsspread, | |||
float * | avrgkeysperslot, | |||
float * | spread | |||
) | const [inline, inherited] |
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().
void FX::QDictBase< keytype, type >::statistics | ( | ) | const [inline, inherited] |
Prints some statistics about the hash table (only debug builds).
Reimplemented in FX::FXLRUCache< FX::QIntDict< type > >, and FX::FXLRUCache< FX::QDict< type > >.
FXint FX::QDictBase< keytype, type >::dictionaryBias | ( | ) | const throw () [inline, inherited] |
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.