1 #ifndef _KVI_POINTERHASHTABLE_H_
2 #define _KVI_POINTERHASHTABLE_H_
49 inline unsigned int kvi_hash_hash(
const char * szKey,
bool bCaseSensitive)
51 unsigned int uResult = 0;
56 uResult += (
unsigned char)(*(szKey));
64 uResult += (
unsigned char)tolower(*(szKey));
78 while(*szKey1 && *szKey2)
80 if(*szKey1 != *szKey2)
88 while(*szKey1 && *szKey2)
90 if(tolower(*szKey1) != tolower(*szKey2))
97 if(*szKey1 || *szKey2)
109 #if defined(COMPILE_ON_WINDOWS)
140 static const char * static_null =
NULL;
149 unsigned int uResult = 0;
150 const char *
p = szKey.
ptr();
155 uResult += *((
const unsigned char *)p);
163 uResult += tolower(*((
const unsigned char *)p));
206 return (
unsigned int)iKey;
214 return iKey1 == iKey2;
237 static int static_default = 0;
238 return static_default;
246 return (
unsigned int)iKey;
254 return iKey1 == iKey2;
277 static unsigned short static_default = 0;
278 return static_default;
286 unsigned char * pBytes = (
unsigned char *)&(pKey);
287 unsigned char * pEnd = pBytes +
sizeof(
void *);
288 unsigned int uSum = 0;
302 return pKey1 == pKey2;
325 static void * static_default =
NULL;
326 return static_default;
332 inline unsigned int kvi_hash_hash(
const QString & szKey,
bool bCaseSensitive)
334 unsigned int uResult = 0;
335 const QChar *
p = szKey.constData();
342 uResult += p->unicode();
350 uResult += p->toLower().unicode();
390 template <
typename Key,
typename T>
392 template <
typename Key,
typename T>
395 template <
typename Key,
typename T>
448 template <
class Key,
class T>
479 return (T *)
e->pData;
581 bool remove(
const Key & hKey)
592 delete((T *)(
e->pData));
627 delete((T *)(
e->pData));
662 delete((T *)(
e->pData));
923 m_uSize = uSize > 0 ? uSize : 32;
965 template <
typename Key,
typename T>
1232 #endif //_KVI_POINTERHASHTABLE_H_
void clear()
Removes all the items from the hash table.
Definition: KviPointerHashTable.h:650
void kvi_hash_key_destroy(const char *&szKey, bool bDeepCopy)
Hash key destruction function for the char * data type.
Definition: KviPointerHashTable.h:129
T * pData
Definition: KviPointerHashTable.h:401
Definition: KviCString.h:105
T * operator*() const
Returs the value pointed by the iterator.
Definition: KviPointerHashTable.h:1177
T * operator[](const Key &hKey)
Returns the item associated to the key hKey.
Definition: KviPointerHashTable.h:493
This file contains the definition of the debug macros;.
T * toFirst()
Moves the iterator to the first element of the hash table.
Definition: KviPointerHashTable.h:1201
KviPointerHashTableEntry< Key, T > * currentEntry()
Returns the entry pointed by the hash table iterator.
Definition: KviPointerHashTable.h:710
char * NULL
Definition: KviIrcNumericCodes.h:391
void append(const T *d)
Appends an item at the end of the list.
Definition: KviPointerList.h:900
T * first()
Places the hash table iterator at the first entry.
Definition: KviPointerHashTable.h:814
bool removeRef(const T *pRef)
Removes the first occurrence of the item pointer pRef.
Definition: KviPointerHashTable.h:615
Key & key()
Definition: KviPointerHashTable.h:405
T * data()
Definition: KviPointerHashTable.h:406
T * find(const Key &hKey)
Returns the item associated to the key.
Definition: KviPointerHashTable.h:471
bool movePrev()
Moves the iterator to the previous element of the list.
Definition: KviPointerList.h:270
#define n
Definition: detector.cpp:78
unsigned int m_uSize
Definition: KviPointerHashTable.h:456
bool moveLast()
Moves the iterator to the last element of the list.
Definition: KviPointerList.h:225
void replace(const Key &hKey, T *pData)
Inserts the item pData at the position specified by the key hKey.
Definition: KviPointerHashTable.h:567
KviPointerHashTable(KviPointerHashTable< Key, T > &t)
First creates an empty hash table and then inserts a copy of all the item pointers present in t...
Definition: KviPointerHashTable.h:936
A fast pointer hash table iterator implementation.
Definition: KviPointerHashTable.h:393
T * first()
Returns the first item in the list.
Definition: KviPointerList.h:637
void insert(KviPointerHashTable< Key, T > &t)
Inserts a complete shallow copy of the data contained in t.
Definition: KviPointerHashTable.h:890
#define e
Definition: detector.cpp:69
T * next()
Returns the next item in the list.
Definition: KviPointerList.h:786
#define kvi_strLen(str)
Definition: KviCString.h:70
bool moveFirst()
Moves the iterator to the first element of the list.
Definition: KviPointerList.h:213
#define i
Definition: detector.cpp:73
bool moveNext()
Moves the iterator to the next element of the hash table.
Definition: KviPointerHashTable.h:1064
bool movePrev()
Moves the iterator to the previous element of the hash table.
Definition: KviPointerHashTable.h:1113
~KviPointerHashTableIterator()
Destroys the iterator.
Definition: KviPointerHashTable.h:1225
T * current()
Returns the current iteration item.
Definition: KviPointerList.h:746
bool kvi_hash_key_equal(const char *szKey1, const char *szKey2, bool bCaseSensitive)
Hash key compare function for the char * data type.
Definition: KviPointerHashTable.h:74
unsigned int count() const
Returns the number of items in this hash table.
Definition: KviPointerHashTable.h:502
bool isEmpty() const
Returns true if the hash table is empty.
Definition: KviPointerHashTable.h:511
KviPointerList< KviPointerHashTableEntry< Key, T > > ** m_pDataArray
Definition: KviPointerHashTable.h:454
const QString Empty
A global empty string (note that this is ALSO NULL under Qt 3.x)
Definition: KviQString.cpp:49
bool removeRef(const T *d)
Removes the item pointed by d (if found in the list)
Definition: KviPointerList.h:1139
KviPointerHashTableEntry< Key, T > * firstEntry()
Places the hash table iterator at the first entry and returns it.
Definition: KviPointerHashTable.h:723
const Key & currentKey() const
Returs the key pointed by the iterator.
Definition: KviPointerHashTable.h:1188
KviPointerListIterator< KviPointerHashTableEntry< Key, T > > * m_pIterator
Definition: KviPointerHashTable.h:971
void copyFrom(KviPointerHashTable< Key, T > &t)
Removes all items in the hash table and then makes a complete shallow copy of the data contained in t...
Definition: KviPointerHashTable.h:876
const Key & currentKey()
Returns the key pointed by the hash table iterator.
Definition: KviPointerHashTable.h:795
unsigned int m_uCount
Definition: KviPointerHashTable.h:457
KviPointerHashTable(unsigned int uSize=32, bool bCaseSensitive=true, bool bDeepCopyKeys=true)
Creates an empty hash table.
Definition: KviPointerHashTable.h:917
unsigned int m_uIteratorIdx
Definition: KviPointerHashTable.h:460
T * next()
Places the hash table iterator at the next entry and returns the associated data value pointer...
Definition: KviPointerHashTable.h:836
bool moveNext()
Moves the iterator to the next element of the list.
Definition: KviPointerList.h:238
void kvi_hash_key_copy(const char *const &szFrom, const char *&szTo, bool bDeepCopy)
Hash key copy function for the char * data type.
Definition: KviPointerHashTable.h:105
void insert(const Key &hKey, T *pData)
Inserts the item pData at the position specified by the key hKey.
Definition: KviPointerHashTable.h:526
QHashIterator< int, QFile * > t(getDict)
T * current()
Returs the value pointed by the iterator.
Definition: KviPointerList.h:301
bool moveLast()
Moves the iterator to the last element of the hash table.
Definition: KviPointerHashTable.h:1030
C++ Template based double linked pointer list class.
KviPointerHashTableEntry< Key, T > * nextEntry()
Places the hash table iterator at the next entry and returns it.
Definition: KviPointerHashTable.h:742
void * allocate(int size)
COMPILE_MEMORY_PROFILE.
Definition: KviMemory.h:113
A template double linked list of pointers.
Definition: KviPointerList.h:55
This file contains an internal implementation of the malloc/free functions.
bool m_bCaseSensitive
Definition: KviPointerHashTable.h:458
KviPointerHashTableEntry< Key, T > * findRef(const T *pRef)
Searches for the item pointer pRef.
Definition: KviPointerHashTable.h:687
bool operator--()
Moves the iterator to the previous element of the hash table.
Definition: KviPointerHashTable.h:1153
void setAutoDelete(bool bAutoDelete)
Enables or disabled the autodeletion feature.
Definition: KviPointerHashTable.h:903
Key hKey
Definition: KviPointerHashTable.h:402
const KviPointerHashTable< Key, T > * m_pHashTable
Definition: KviPointerHashTable.h:969
T * current()
Returns the data value pointer pointed by the hash table iterator.
Definition: KviPointerHashTable.h:774
void operator=(const KviPointerHashTableIterator< Key, T > &src)
Creates an iterator copy.
Definition: KviPointerHashTable.h:981
bool equalCI(const QString &sz1, const QString &sz2)
Compares two strings with case insensitive.
Definition: KviQString.cpp:285
unsigned int kvi_hash_hash(const char *szKey, bool bCaseSensitive)
Hash function for the char * data type.
Definition: KviPointerHashTable.h:49
bool m_bAutoDelete
Definition: KviPointerHashTable.h:455
bool m_bDeepCopyKeys
Definition: KviPointerHashTable.h:459
A fast pointer hash table implementation.
Definition: KviPointerHashTable.h:391
T * current() const
Returs the value pointed by the iterator.
Definition: KviPointerHashTable.h:1165
Definition: KviPointerHashTable.h:396
const char *& kvi_hash_key_default(const char **)
Default (empty) hash key for the char * data type.
Definition: KviPointerHashTable.h:138
This file contains compile time settings.
char * ptr() const
Definition: KviCString.h:172
void copy(void *dst_ptr, const void *src_ptr, int len)
Moves len bytes from src_ptr to dst_ptr.
Definition: KviMemory.h:166
void free(void *ptr)
COMPILE_MEMORY_CHECKS.
Definition: KviMemory.h:125
bool equalCS(const QString &sz1, const QString &sz2)
Compares two strings with case sensitive.
Definition: KviQString.cpp:257
bool moveFirst()
Moves the iterator to the first element of the hash table.
Definition: KviPointerHashTable.h:997
#define p
Definition: detector.cpp:80
KviPointerHashTableIterator(const KviPointerHashTable< Key, T > &hTable)
Creates an iterator pointing to the first item in the hash table, if any.
Definition: KviPointerHashTable.h:1214
A fast KviPointerList iterator.
Definition: KviPointerList.h:57
Helper functions for the QString class.
static KviCString & emptyString()
Definition: KviCString.cpp:3159
unsigned int m_uEntryIndex
Definition: KviPointerHashTable.h:970
~KviPointerHashTable()
Destroys the hash table and all the items contained within.
Definition: KviPointerHashTable.h:954
bool operator++()
Moves the iterator to the next element of the hash table.
Definition: KviPointerHashTable.h:1100