File indexing completed on 2025-01-18 10:15:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #if !defined(XERCESC_INCLUDE_GUARD_REFHASH3KEYSIDPOOL_HPP)
0023 #define XERCESC_INCLUDE_GUARD_REFHASH3KEYSIDPOOL_HPP
0024
0025
0026 #include <xercesc/util/Hashers.hpp>
0027 #include <xercesc/util/IllegalArgumentException.hpp>
0028 #include <xercesc/util/NoSuchElementException.hpp>
0029 #include <xercesc/util/RuntimeException.hpp>
0030 #include <xercesc/util/PlatformUtils.hpp>
0031
0032 XERCES_CPP_NAMESPACE_BEGIN
0033
0034
0035
0036
0037
0038
0039 template <class TVal, class THasher = StringHasher>
0040 class RefHash3KeysIdPoolEnumerator;
0041
0042
0043
0044
0045
0046
0047 template <class TVal>
0048 struct RefHash3KeysTableBucketElem
0049 {
0050 RefHash3KeysTableBucketElem(
0051 void* key1
0052 , int key2
0053 , int key3
0054 , TVal* const value
0055 , RefHash3KeysTableBucketElem<TVal>* next) :
0056 fData(value)
0057 , fNext(next)
0058 , fKey1(key1)
0059 , fKey2(key2)
0060 , fKey3(key3)
0061 {
0062 }
0063
0064 RefHash3KeysTableBucketElem() {};
0065 ~RefHash3KeysTableBucketElem() {};
0066
0067 TVal* fData;
0068 RefHash3KeysTableBucketElem<TVal>* fNext;
0069 void* fKey1;
0070 int fKey2;
0071 int fKey3;
0072
0073 private:
0074
0075
0076
0077 RefHash3KeysTableBucketElem(const RefHash3KeysTableBucketElem<TVal>&);
0078 RefHash3KeysTableBucketElem<TVal>& operator=(const RefHash3KeysTableBucketElem<TVal>&);
0079 };
0080
0081
0082 template <class TVal, class THasher = StringHasher>
0083 class RefHash3KeysIdPool : public XMemory
0084 {
0085 public:
0086
0087
0088
0089 RefHash3KeysIdPool(
0090 const XMLSize_t modulus,
0091 const XMLSize_t initSize = 128,
0092 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0093
0094 RefHash3KeysIdPool(
0095 const XMLSize_t modulus,
0096 const THasher& hasher,
0097 const XMLSize_t initSize = 128,
0098 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0099
0100 RefHash3KeysIdPool(
0101 const XMLSize_t modulus,
0102 const bool adoptElems,
0103 const XMLSize_t initSize = 128,
0104 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0105
0106 RefHash3KeysIdPool(
0107 const XMLSize_t modulus,
0108 const bool adoptElems,
0109 const THasher& hasher,
0110 const XMLSize_t initSize = 128,
0111 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0112
0113 ~RefHash3KeysIdPool();
0114
0115
0116
0117
0118 bool isEmpty() const;
0119 bool containsKey(const void* const key1, const int key2, const int key3) const;
0120 void removeAll();
0121
0122
0123
0124
0125
0126 TVal* getByKey(const void* const key1, const int key2, const int key3);
0127 const TVal* getByKey(const void* const key1, const int key2, const int key3) const;
0128
0129 TVal* getById(const unsigned int elemId);
0130 const TVal* getById(const unsigned int elemId) const;
0131
0132 MemoryManager* getMemoryManager() const;
0133 XMLSize_t getHashModulus() const;
0134
0135
0136
0137
0138 XMLSize_t put(void* key1, int key2, int key3, TVal* const valueToAdopt);
0139
0140
0141 private :
0142
0143
0144
0145 friend class RefHash3KeysIdPoolEnumerator<TVal, THasher>;
0146
0147 private:
0148
0149
0150
0151 RefHash3KeysIdPool(const RefHash3KeysIdPool<TVal, THasher>&);
0152 RefHash3KeysIdPool<TVal, THasher>& operator=(const RefHash3KeysIdPool<TVal, THasher>&);
0153
0154
0155
0156
0157 RefHash3KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, const int key3, XMLSize_t& hashVal);
0158 const RefHash3KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, const int key3, XMLSize_t& hashVal) const;
0159 void initialize(const XMLSize_t modulus);
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195 MemoryManager* fMemoryManager;
0196 bool fAdoptedElems;
0197 RefHash3KeysTableBucketElem<TVal>** fBucketList;
0198 XMLSize_t fHashModulus;
0199 TVal** fIdPtrs;
0200 XMLSize_t fIdPtrsCount;
0201 XMLSize_t fIdCounter;
0202 THasher fHasher;
0203 };
0204
0205
0206
0207
0208
0209
0210
0211 template <class TVal, class THasher>
0212 class RefHash3KeysIdPoolEnumerator : public XMLEnumerator<TVal>, public XMemory
0213 {
0214 public :
0215
0216
0217
0218 RefHash3KeysIdPoolEnumerator(RefHash3KeysIdPool<TVal, THasher>* const toEnum
0219 , const bool adopt = false
0220 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0221 virtual ~RefHash3KeysIdPoolEnumerator();
0222
0223 RefHash3KeysIdPoolEnumerator(const RefHash3KeysIdPoolEnumerator<TVal, THasher>&);
0224
0225
0226
0227 bool hasMoreElements() const;
0228 TVal& nextElement();
0229 void Reset();
0230 XMLSize_t size() const;
0231
0232
0233
0234
0235 void resetKey();
0236 void nextElementKey(void*&, int&, int&);
0237 bool hasMoreKeys() const;
0238
0239 private :
0240
0241
0242
0243 RefHash3KeysIdPoolEnumerator<TVal, THasher>&
0244 operator=(const RefHash3KeysIdPoolEnumerator<TVal, THasher>&);
0245
0246
0247
0248
0249 void findNext();
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265 bool fAdoptedElems;
0266 XMLSize_t fCurIndex;
0267 RefHash3KeysIdPool<TVal, THasher>* fToEnum;
0268 RefHash3KeysTableBucketElem<TVal>* fCurElem;
0269 XMLSize_t fCurHash;
0270 MemoryManager* const fMemoryManager;
0271 };
0272
0273 XERCES_CPP_NAMESPACE_END
0274
0275 #if !defined(XERCES_TMPLSINC)
0276 #include <xercesc/util/RefHash3KeysIdPool.c>
0277 #endif
0278
0279 #endif