KVIrc 5.2.0
Developer APIs
KviPointerHashTable.h
Go to the documentation of this file.
1#ifndef _KVI_POINTERHASHTABLE_H_
2#define _KVI_POINTERHASHTABLE_H_
3//============================================================================
4//
5// File : KviPointerHashTable.h
6// Creation date : Sat Jan 12 2008 04:53 by Szymon Stefanek
7//
8// This file is part of the KVIrc IRC client distribution
9// Copyright (C) 2008 Szymon Stefanek (pragma at kvirc dot net)
10//
11// This program is FREE software. You can redistribute it and/or
12// modify it under the terms of the GNU General Public License
13// as published by the Free Software Foundation; either version 2
14// of the License, or (at your option) any later version.
15//
16// This program is distributed in the HOPE that it will be USEFUL,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19// See the GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program. If not, write to the Free Software Foundation,
23// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24//
25//============================================================================
26
33#include "kvi_settings.h"
34#include "KviPointerList.h"
35#include "KviCString.h"
36#include "KviQString.h"
37#include "KviMemory.h"
38#include "kvi_debug.h"
39
40#include <ctype.h>
41
45
49inline unsigned int kvi_hash_hash(const char * szKey, bool bCaseSensitive)
50{
51 unsigned int uResult = 0;
52 if(bCaseSensitive)
53 {
54 while(*szKey)
55 {
56 uResult += (unsigned char)(*(szKey));
57 szKey++;
58 }
59 }
60 else
61 {
62 while(*szKey)
63 {
64 uResult += (unsigned char)tolower(*(szKey));
65 szKey++;
66 }
67 }
68 return uResult;
69}
70
74inline bool kvi_hash_key_equal(const char * szKey1, const char * szKey2, bool bCaseSensitive)
75{
76 if(bCaseSensitive)
77 {
78 while(*szKey1 && *szKey2)
79 {
80 if(*szKey1 != *szKey2)
81 return false;
82 szKey1++;
83 szKey2++;
84 }
85 }
86 else
87 {
88 while(*szKey1 && *szKey2)
89 {
90 if(tolower(*szKey1) != tolower(*szKey2))
91 return false;
92 szKey1++;
93 szKey2++;
94 }
95 }
96 //check if one of the strings is a substring of the other (like "perl" and "perlcore")
97 if(*szKey1 || *szKey2)
98 return false;
99 return true;
100}
101
105inline void kvi_hash_key_copy(const char * const & szFrom, const char *& szTo, bool bDeepCopy)
106{
107 if(bDeepCopy)
108 {
109#if defined(COMPILE_ON_WINDOWS)
110 // strlen() returns size_t under windows, which is 32 bits long on a 32 bits
111 // system and 64 bits long on a 64 bits one. cast it to avoid a warning
112 int len = (int)kvi_strLen(szFrom);
113#else
114 int len = kvi_strLen(szFrom);
115#endif
116 char * dst = (char *)KviMemory::allocate(len + 1);
117 KviMemory::copy(dst, szFrom, len + 1);
118 szTo = dst;
119 }
120 else
121 {
122 szTo = szFrom; // we never modify it anyway
123 }
124}
125
129inline void kvi_hash_key_destroy(const char *& szKey, bool bDeepCopy)
130{
131 if(bDeepCopy)
132 KviMemory::free((char *)szKey);
133}
134
138inline const char *& kvi_hash_key_default(const char **)
139{
140 static const char * static_null = nullptr;
141 return static_null;
142}
143
147inline unsigned int kvi_hash_hash(const KviCString & szKey, bool bCaseSensitive)
148{
149 unsigned int uResult = 0;
150 const char * p = szKey.ptr();
151 if(bCaseSensitive)
152 {
153 while(*p)
154 {
155 uResult += *((const unsigned char *)p);
156 p++;
157 }
158 }
159 else
160 {
161 while(*p)
162 {
163 uResult += tolower(*((const unsigned char *)p));
164 p++;
165 }
166 }
167 return uResult;
168}
169
173inline bool kvi_hash_key_equal(const KviCString & szKey1, const KviCString & szKey2)
174{
175 return kvi_hash_key_equal(szKey1.ptr(), szKey2.ptr());
176}
177
181inline void kvi_hash_key_copy(const KviCString & szFrom, KviCString & szTo, bool)
182{
183 szTo = szFrom;
184}
185
190{
191}
192
197{
199}
200
204inline unsigned int kvi_hash_hash(const int & iKey, bool)
205{
206 return (unsigned int)iKey;
207}
208
212inline bool kvi_hash_key_equal(const int & iKey1, const int & iKey2, bool)
213{
214 return iKey1 == iKey2;
215}
216
220inline void kvi_hash_key_copy(const int & iKeyFrom, int & iKeyTo, bool)
221{
222 iKeyTo = iKeyFrom;
223}
224
228inline void kvi_hash_key_destroy(int &, bool)
229{
230}
231
235inline const int & kvi_hash_key_default(int *)
236{
237 static int static_default = 0;
238 return static_default;
239}
240
244inline unsigned int kvi_hash_hash(const unsigned short & iKey, bool)
245{
246 return (unsigned int)iKey;
247}
248
252inline bool kvi_hash_key_equal(const unsigned short & iKey1, const unsigned short & iKey2, bool)
253{
254 return iKey1 == iKey2;
255}
256
260inline void kvi_hash_key_copy(const unsigned short & iKeyFrom, unsigned short & iKeyTo, bool)
261{
262 iKeyTo = iKeyFrom;
263}
264
268inline void kvi_hash_key_destroy(unsigned short &, bool)
269{
270}
271
275inline const unsigned short & kvi_hash_key_default(unsigned short *)
276{
277 static unsigned short static_default = 0;
278 return static_default;
279}
280
284inline unsigned int kvi_hash_hash(void * pKey, bool)
285{
286 unsigned char * pBytes = (unsigned char *)&(pKey);
287 unsigned char * pEnd = pBytes + sizeof(void *);
288 unsigned int uSum = 0;
289 while(pBytes < pEnd)
290 {
291 uSum += *pBytes;
292 pBytes++;
293 }
294 return uSum;
295}
296
300inline bool kvi_hash_key_equal(void * pKey1, void * pKey2, bool)
301{
302 return pKey1 == pKey2;
303}
304
308inline void kvi_hash_key_copy(void * const & pKeyFrom, void *& pKeyTo, bool)
309{
310 pKeyTo = pKeyFrom;
311}
312
316inline void kvi_hash_key_destroy(void *, bool)
317{
318}
319
323inline void *& kvi_hash_key_default(void *)
324{
325 static void * static_default = nullptr;
326 return static_default;
327}
328
332inline unsigned int kvi_hash_hash(const QString & szKey, bool bCaseSensitive)
333{
334 unsigned int uResult = 0;
335 const QChar * p = szKey.constData();
336 if(!p)
337 return 0;
338 if(bCaseSensitive)
339 {
340 while(p->unicode())
341 {
342 uResult += p->unicode();
343 p++;
344 }
345 }
346 else
347 {
348 while(p->unicode())
349 {
350 uResult += p->toLower().unicode();
351 p++;
352 }
353 }
354 return uResult;
355}
356
360inline bool kvi_hash_key_equal(const QString & szKey1, const QString & szKey2, bool bCaseSensitive)
361{
362 if(bCaseSensitive)
363 return KviQString::equalCS(szKey1, szKey2);
364 return KviQString::equalCI(szKey1, szKey2);
365}
366
370inline void kvi_hash_key_copy(const QString & szFrom, QString & szTo, bool)
371{
372 szTo = szFrom;
373}
374
378inline void kvi_hash_key_destroy(QString &, bool)
379{
380}
381
385inline const QString & kvi_hash_key_default(QString *)
386{
387 return KviQString::Empty;
388}
389
390template <typename Key, typename T>
392template <typename Key, typename T>
394
395template <typename Key, typename T>
397{
398 friend class KviPointerHashTable<Key, T>;
399
400protected:
401 T * pData;
402 Key hKey;
403
404public:
405 Key & key() { return hKey; };
406 T * data() { return pData; };
407};
408
448template <class Key, class T>
450{
451 friend class KviPointerHashTableIterator<Key, T>;
452
453protected:
456 unsigned int m_uSize;
457 unsigned int m_uCount;
460 unsigned int m_uIteratorIdx = 0;
461
462public:
471 T * find(const Key & hKey)
472 {
475 return nullptr;
477 {
478 if(kvi_hash_key_equal(e->hKey, hKey, m_bCaseSensitive))
479 return (T *)e->pData;
480 }
481 return nullptr;
482 }
483
493 T * operator[](const Key & hKey)
494 {
495 return find(hKey);
496 }
497
502 unsigned int count() const
503 {
504 return m_uCount;
505 }
506
511 bool isEmpty() const
512 {
513 return m_uCount == 0;
514 }
515
526 void insert(const Key & hKey, T * pData)
527 {
528 if(!pData)
529 return;
530 unsigned int uEntry = kvi_hash_hash(hKey, m_bCaseSensitive) % m_uSize;
531 if(!m_pDataArray[uEntry])
533 for(KviPointerHashTableEntry<Key, T> * e = m_pDataArray[uEntry]->first(); e; e = m_pDataArray[uEntry]->next())
534 {
535 if(kvi_hash_key_equal(e->hKey, hKey, m_bCaseSensitive))
536 {
538 {
539 // must change the key too
541 kvi_hash_key_copy(hKey, e->hKey, m_bDeepCopyKeys);
542 }
543 if(m_bAutoDelete)
544 delete e->pData;
545 e->pData = pData;
546 return;
547 }
548 }
550 kvi_hash_key_copy(hKey, n->hKey, m_bDeepCopyKeys);
551 n->pData = pData;
552 m_pDataArray[uEntry]->append(n);
553 m_uCount++;
554 }
555
567 void replace(const Key & hKey, T * pData)
568 {
569 insert(hKey, pData);
570 }
571
581 bool remove(const Key & hKey)
582 {
583 unsigned int uEntry = kvi_hash_hash(hKey, m_bCaseSensitive) % m_uSize;
584 if(!m_pDataArray[uEntry])
585 return false;
586 for(KviPointerHashTableEntry<Key, T> * e = m_pDataArray[uEntry]->first(); e; e = m_pDataArray[uEntry]->next())
587 {
588 if(kvi_hash_key_equal(e->hKey, hKey, m_bCaseSensitive))
589 {
591 if(m_bAutoDelete)
592 delete((T *)(e->pData));
593 m_pDataArray[uEntry]->removeRef(e);
594 if(m_pDataArray[uEntry]->isEmpty())
595 {
596 delete m_pDataArray[uEntry];
597 m_pDataArray[uEntry] = nullptr;
598 }
599 m_uCount--;
600 return true;
601 }
602 }
603 return false;
604 }
605
615 bool removeRef(const T * pRef)
616 {
617 for(unsigned int i = 0; i < m_uSize; i++)
618 {
619 if(m_pDataArray[i])
620 {
622 {
623 if(e->pData == pRef)
624 {
626 if(m_bAutoDelete)
627 delete((T *)(e->pData));
629 if(m_pDataArray[i]->isEmpty())
630 {
631 delete m_pDataArray[i];
632 m_pDataArray[i] = nullptr;
633 }
634 m_uCount--;
635 return true;
636 }
637 }
638 }
639 }
640 return false;
641 }
642
650 void clear()
651 {
652 for(unsigned int i = 0; i < m_uSize; i++)
653 {
654 if(!m_pDataArray[i])
655 continue;
656
657 while(KviPointerHashTableEntry<Key, T> * e = m_pDataArray[i]->takeFirst())
658 {
660
661 if(m_bAutoDelete)
662 delete((T *)(e->pData));
663
664 delete e;
665
666 if(!m_pDataArray[i])
667 break; // emptied in the meantime
668 }
669
670 if(m_pDataArray[i])
671 {
672 delete m_pDataArray[i];
673 m_pDataArray[i] = nullptr;
674 }
675 }
676 m_uCount = 0;
677 }
678
688 {
690 {
692 {
694 {
695 if(e->pData == pRef)
696 return e;
697 }
698 }
699 }
700 return nullptr;
701 }
702
711 {
713 return nullptr;
716 return nullptr;
717 }
718
724 {
725 m_uIteratorIdx = 0;
727 {
729 }
731 return nullptr;
733 }
734
743 {
745 return nullptr;
746
748 {
750 if(t)
751 return t;
752 }
753
755
757 {
759 }
760
762 return nullptr;
763
765 }
766
775 {
777 return nullptr;
779 {
781 if(!e)
782 return nullptr;
783 return e->data();
784 }
785 return nullptr;
786 }
787
795 const Key & currentKey()
796 {
798 return kvi_hash_key_default(((Key *)nullptr));
800 {
802 if(!e)
803 return kvi_hash_key_default(((Key *)nullptr));
804 return e->key();
805 }
806 return kvi_hash_key_default(((Key *)nullptr));
807 }
808
814 T * first()
815 {
816 m_uIteratorIdx = 0;
818 {
820 }
822 return nullptr;
824 if(!e)
825 return nullptr;
826 return e->data();
827 }
828
836 T * next()
837 {
839 return nullptr;
840
842 {
844 if(t)
845 {
846 return t->data();
847 }
848 }
849
851
853 {
855 }
856
858 return nullptr;
859
861 if(!e)
862 return nullptr;
863 return e->data();
864 }
865
877 {
878 clear();
879 for(KviPointerHashTableEntry<Key, T> * e = t.firstEntry(); e; e = t.nextEntry())
880 insert(e->key(), e->data());
881 }
882
891 {
892 for(KviPointerHashTableEntry<Key, T> * e = t.firstEntry(); e; e = t.nextEntry())
893 insert(e->key(), e->data());
894 }
895
903 void setAutoDelete(bool bAutoDelete)
904 {
905 m_bAutoDelete = bAutoDelete;
906 }
907
917 KviPointerHashTable(unsigned int uSize = 32, bool bCaseSensitive = true, bool bDeepCopyKeys = true)
918 {
919 m_uCount = 0;
920 m_bCaseSensitive = bCaseSensitive;
921 m_bAutoDelete = true;
922 m_bDeepCopyKeys = bDeepCopyKeys;
923 m_uSize = uSize > 0 ? uSize : 32;
925 for(unsigned int i = 0; i < m_uSize; i++)
926 m_pDataArray[i] = nullptr;
927 }
928
937 {
938 m_uCount = 0;
939 m_bAutoDelete = false;
940 m_bCaseSensitive = t.m_bCaseSensitive;
941 m_bDeepCopyKeys = t.m_bDeepCopyKeys;
942 m_uSize = t.m_uSize;
944 for(unsigned int i = 0; i < m_uSize; i++)
945 m_pDataArray[i] = nullptr;
946 copyFrom(t);
947 }
948
955 {
956 clear();
957 delete[] m_pDataArray;
958 }
959};
960
965template <typename Key, typename T>
967{
968protected:
970 unsigned int m_uEntryIndex;
972
973public:
990
998 {
999 if(m_pIterator)
1000 {
1001 delete m_pIterator;
1002 m_pIterator = nullptr;
1003 }
1004
1005 m_uEntryIndex = 0;
1006 while((m_uEntryIndex < m_pHashTable->m_uSize) && (!(m_pHashTable->m_pDataArray[m_uEntryIndex])))
1007 {
1008 m_uEntryIndex++;
1009 }
1010
1011 if(m_uEntryIndex == m_pHashTable->m_uSize)
1012 return false;
1013
1015 bool bRet = m_pIterator->moveFirst();
1016 if(!bRet)
1017 {
1018 delete m_pIterator;
1019 m_pIterator = nullptr;
1020 }
1021 return bRet;
1022 }
1023
1031 {
1032 if(m_pIterator)
1033 {
1034 delete m_pIterator;
1035 m_pIterator = nullptr;
1036 }
1037
1038 m_uEntryIndex = m_pHashTable->m_uSize;
1039 while(m_uEntryIndex > 0)
1040 {
1041 m_uEntryIndex--;
1042 if(m_pHashTable->m_pDataArray[m_uEntryIndex])
1043 {
1045 bool bRet = m_pIterator->moveLast();
1046 if(!bRet)
1047 {
1048 delete m_pIterator;
1049 m_pIterator = nullptr;
1050 }
1051 return bRet;
1052 }
1053 }
1054 return false;
1055 }
1056
1065 {
1066 if(!m_pIterator)
1067 return false;
1068 if(m_pIterator->moveNext())
1069 return true;
1070 if(m_pIterator)
1071 {
1072 delete m_pIterator;
1073 m_pIterator = nullptr;
1074 }
1075 m_uEntryIndex++;
1076 while((m_uEntryIndex < m_pHashTable->m_uSize) && (!(m_pHashTable->m_pDataArray[m_uEntryIndex])))
1077 {
1078 m_uEntryIndex++;
1079 }
1080 if(m_uEntryIndex == m_pHashTable->m_uSize)
1081 return false;
1083 bool bRet = m_pIterator->moveFirst();
1084 if(!bRet)
1085 {
1086 delete m_pIterator;
1087 m_pIterator = nullptr;
1088 }
1089 return bRet;
1090 }
1091
1101 {
1102 return moveNext();
1103 }
1104
1114 {
1115 if(!m_pIterator)
1116 return false;
1117 if(m_pIterator->movePrev())
1118 return true;
1119 if(m_pIterator)
1120 {
1121 delete m_pIterator;
1122 m_pIterator = nullptr;
1123 }
1124 if(m_uEntryIndex >= m_pHashTable->m_uSize)
1125 return false;
1126 while(m_uEntryIndex > 0)
1127 {
1128 m_uEntryIndex--;
1129 if(m_pHashTable->m_pDataArray[m_uEntryIndex])
1130 {
1132 bool bRet = m_pIterator->moveLast();
1133 if(!bRet)
1134 {
1135 delete m_pIterator;
1136 m_pIterator = nullptr;
1137 }
1138 return bRet;
1139 }
1140 }
1141 return false;
1142 }
1143
1154 {
1155 return movePrev();
1156 }
1157
1165 T * current() const
1166 {
1167 return m_pIterator ? m_pIterator->current()->data() : nullptr;
1168 }
1169
1177 T * operator*() const
1178 {
1179 return m_pIterator ? m_pIterator->current()->data() : nullptr;
1180 }
1181
1188 const Key & currentKey() const
1189 {
1190 if(m_pIterator)
1191 return m_pIterator->current()->key();
1192 return kvi_hash_key_default(((Key *)nullptr));
1193 }
1194
1202 {
1203 if(!moveFirst())
1204 return nullptr;
1205 return current();
1206 }
1207
1208public:
1215 {
1216 m_pHashTable = &hTable;
1217 m_uEntryIndex = 0;
1218 m_pIterator = nullptr;
1219 moveFirst();
1220 }
1221
1226 {
1227 if(m_pIterator)
1228 delete m_pIterator;
1229 }
1230};
1231
1232#endif //_KVI_POINTERHASHTABLE_H_
#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