1#ifndef _KVI_POINTERHASHTABLE_H_
2#define _KVI_POINTERHASHTABLE_H_
49inline 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 =
nullptr;
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 =
nullptr;
326 return static_default;
332inline 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();
390template <
typename Key,
typename T>
392template <
typename Key,
typename T>
395template <
typename Key,
typename T>
448template <
class Key,
class T>
479 return (T *)
e->pData;
592 delete((T *)(
e->pData));
627 delete((T *)(
e->pData));
662 delete((T *)(
e->pData));
923 m_uSize = uSize > 0 ? uSize : 32;
965template <
typename Key,
typename T>
#define kvi_strLen(str)
Definition KviCString.h:68
This file contains an internal implementation of the malloc/free functions.
unsigned int kvi_hash_hash(const char *szKey, bool bCaseSensitive)
Hash function for the char * data type.
Definition KviPointerHashTable.h:49
void kvi_hash_key_destroy(const char *&szKey, bool bDeepCopy)
Hash key destruction function for the char * data type.
Definition KviPointerHashTable.h:129
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
const char *& kvi_hash_key_default(const char **)
Default (empty) hash key for the char * data type.
Definition KviPointerHashTable.h:138
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
C++ Template based double linked pointer list class.
Helper functions for the QString class.
Definition KviCString.h:102
char * ptr() const
Definition KviCString.h:163
static KviCString & emptyString()
Definition KviCString.cpp:3171
Definition KviPointerHashTable.h:397
Key hKey
Definition KviPointerHashTable.h:402
T * data()
Definition KviPointerHashTable.h:406
Key & key()
Definition KviPointerHashTable.h:405
T * pData
Definition KviPointerHashTable.h:401
A fast pointer hash table iterator implementation.
Definition KviPointerHashTable.h:967
const Key & currentKey() const
Returns the key pointed by the iterator.
Definition KviPointerHashTable.h:1188
unsigned int m_uEntryIndex
Definition KviPointerHashTable.h:970
const KviPointerHashTable< Key, T > * m_pHashTable
Definition KviPointerHashTable.h:969
bool moveNext()
Moves the iterator to the next element of the hash table.
Definition KviPointerHashTable.h:1064
bool moveFirst()
Moves the iterator to the first element of the hash table.
Definition KviPointerHashTable.h:997
bool movePrev()
Moves the iterator to the previous element of the hash table.
Definition KviPointerHashTable.h:1113
T * current() const
Returns the value pointed by the iterator.
Definition KviPointerHashTable.h:1165
T * operator*() const
Returns the value pointed by the iterator.
Definition KviPointerHashTable.h:1177
KviPointerListIterator< KviPointerHashTableEntry< Key, T > > * m_pIterator
Definition KviPointerHashTable.h:971
bool operator++()
Moves the iterator to the next element of the hash table.
Definition KviPointerHashTable.h:1100
~KviPointerHashTableIterator()
Destroys the iterator.
Definition KviPointerHashTable.h:1225
bool operator--()
Moves the iterator to the previous element of the hash table.
Definition KviPointerHashTable.h:1153
void operator=(const KviPointerHashTableIterator< Key, T > &src)
Creates an iterator copy.
Definition KviPointerHashTable.h:981
bool moveLast()
Moves the iterator to the last element of the hash table.
Definition KviPointerHashTable.h:1030
KviPointerHashTableIterator(const KviPointerHashTable< Key, T > &hTable)
Creates an iterator pointing to the first item in the hash table, if any.
Definition KviPointerHashTable.h:1214
T * toFirst()
Moves the iterator to the first element of the hash table.
Definition KviPointerHashTable.h:1201
A fast pointer hash table implementation.
Definition KviPointerHashTable.h:450
void clear()
Removes all the items from the hash table.
Definition KviPointerHashTable.h:650
void insert(KviPointerHashTable< Key, T > &t)
Inserts a complete shallow copy of the data contained in t.
Definition KviPointerHashTable.h:890
bool removeRef(const T *pRef)
Removes the first occurrence of the item pointer pRef.
Definition KviPointerHashTable.h:615
KviPointerHashTableEntry< Key, T > * findRef(const T *pRef)
Searches for the item pointer pRef.
Definition KviPointerHashTable.h:687
T * operator[](const Key &hKey)
Returns the item associated to the key hKey.
Definition KviPointerHashTable.h:493
bool m_bDeepCopyKeys
Definition KviPointerHashTable.h:459
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
bool isEmpty() const
Returns true if the hash table is empty.
Definition KviPointerHashTable.h:511
T * next()
Places the hash table iterator at the next entry and returns the associated data value pointer.
Definition KviPointerHashTable.h:836
KviPointerHashTableEntry< Key, T > * currentEntry()
Returns the entry pointed by the hash table iterator.
Definition KviPointerHashTable.h:710
const Key & currentKey()
Returns the key pointed by the hash table iterator.
Definition KviPointerHashTable.h:795
void replace(const Key &hKey, T *pData)
Inserts the item pData at the position specified by the key hKey.
Definition KviPointerHashTable.h:567
unsigned int count() const
Returns the number of items in this hash table.
Definition KviPointerHashTable.h:502
unsigned int m_uSize
Definition KviPointerHashTable.h:456
unsigned int m_uIteratorIdx
Definition KviPointerHashTable.h:460
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
bool m_bAutoDelete
Definition KviPointerHashTable.h:455
KviPointerHashTableEntry< Key, T > * nextEntry()
Places the hash table iterator at the next entry and returns it.
Definition KviPointerHashTable.h:742
void insert(const Key &hKey, T *pData)
Inserts the item pData at the position specified by the key hKey.
Definition KviPointerHashTable.h:526
~KviPointerHashTable()
Destroys the hash table and all the items contained within.
Definition KviPointerHashTable.h:954
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
bool remove(const Key &hKey)
Removes the item pointer associated to the key hKey, if such an item exists in the hash table.
Definition KviPointerHashTable.h:581
KviPointerList< KviPointerHashTableEntry< Key, T > > ** m_pDataArray
Definition KviPointerHashTable.h:454
bool m_bCaseSensitive
Definition KviPointerHashTable.h:458
T * find(const Key &hKey)
Returns the item associated to the key.
Definition KviPointerHashTable.h:471
void setAutoDelete(bool bAutoDelete)
Enables or disabled the autodeletion feature.
Definition KviPointerHashTable.h:903
KviPointerHashTableEntry< Key, T > * firstEntry()
Places the hash table iterator at the first entry and returns it.
Definition KviPointerHashTable.h:723
T * first()
Places the hash table iterator at the first entry.
Definition KviPointerHashTable.h:814
T * current()
Returns the data value pointer pointed by the hash table iterator.
Definition KviPointerHashTable.h:774
A fast KviPointerList iterator.
Definition KviPointerList.h:142
T * current()
Returns the value pointed by the iterator.
Definition KviPointerList.h:296
bool moveNext()
Moves the iterator to the next element of the list.
Definition KviPointerList.h:233
bool movePrev()
Moves the iterator to the previous element of the list.
Definition KviPointerList.h:265
bool moveFirst()
Moves the iterator to the first element of the list.
Definition KviPointerList.h:208
bool moveLast()
Moves the iterator to the last element of the list.
Definition KviPointerList.h:220
A template double linked list of pointers.
Definition KviPointerList.h:371
void append(const T *d)
Appends an item at the end of the list.
Definition KviPointerList.h:895
T * current()
Returns the current iteration item.
Definition KviPointerList.h:741
T * first()
Returns the first item in the list.
Definition KviPointerList.h:632
bool removeRef(const T *d)
Removes the item pointed by d (if found in the list)
Definition KviPointerList.h:1134
T * next()
Returns the next item in the list.
Definition KviPointerList.h:781
#define i
Definition detector.cpp:74
#define t
Definition detector.cpp:85
#define e
Definition detector.cpp:70
#define n
Definition detector.cpp:79
#define p
Definition detector.cpp:81
This file contains the definition of the debug macros;.
This file contains compile time settings.
void free(void *ptr)
COMPILE_MEMORY_CHECKS.
Definition KviMemory.h:124
void copy(void *dst_ptr, const void *src_ptr, int len)
Moves len bytes from src_ptr to dst_ptr.
Definition KviMemory.h:165
void * allocate(int size)
COMPILE_MEMORY_PROFILE.
Definition KviMemory.h:112
const QString Empty
A global empty string (note that this is ALSO NULL under Qt 3.x)
Definition KviQString.cpp:47
bool equalCS(const QString &sz1, const QString &sz2)
Compares two strings with case sensitive.
Definition KviQString.cpp:255
bool equalCI(const QString &sz1, const QString &sz2)
Compares two strings with case insensitive.
Definition KviQString.cpp:283