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_REFHASH2KEYSTABLEOF_HPP)
0023 #define XERCESC_INCLUDE_GUARD_REFHASH2KEYSTABLEOF_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 template <class TVal, class THasher = StringHasher>
0039 class RefHash2KeysTableOfEnumerator;
0040
0041
0042
0043
0044
0045 template <class TVal>
0046 struct RefHash2KeysTableBucketElem
0047 {
0048 RefHash2KeysTableBucketElem(void* key1, int key2, TVal* const value, RefHash2KeysTableBucketElem<TVal>* next)
0049 : fData(value), fNext(next), fKey1(key1), fKey2(key2)
0050 {
0051 }
0052 ~RefHash2KeysTableBucketElem() {};
0053
0054 TVal* fData;
0055 RefHash2KeysTableBucketElem<TVal>* fNext;
0056 void* fKey1;
0057 int fKey2;
0058
0059 private:
0060
0061
0062
0063 RefHash2KeysTableBucketElem(const RefHash2KeysTableBucketElem<TVal>&);
0064 RefHash2KeysTableBucketElem<TVal>& operator=(const RefHash2KeysTableBucketElem<TVal>&);
0065 };
0066
0067
0068 template <class TVal, class THasher = StringHasher>
0069 class RefHash2KeysTableOf : public XMemory
0070 {
0071 public:
0072
0073
0074
0075
0076 RefHash2KeysTableOf(
0077 const XMLSize_t modulus,
0078 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0079
0080 RefHash2KeysTableOf(
0081 const XMLSize_t modulus,
0082 const THasher& hasher,
0083 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0084
0085 RefHash2KeysTableOf(
0086 const XMLSize_t modulus,
0087 const bool adoptElems,
0088 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0089
0090 RefHash2KeysTableOf(
0091 const XMLSize_t modulus,
0092 const bool adoptElems,
0093 const THasher& hasher,
0094 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0095
0096 ~RefHash2KeysTableOf();
0097
0098
0099
0100
0101
0102 bool isEmpty() const;
0103 bool containsKey(const void* const key1, const int key2) const;
0104 void removeKey(const void* const key1, const int key2);
0105 void removeKey(const void* const key1);
0106 void removeAll();
0107 void transferElement(const void* const key1, void* key2);
0108
0109
0110
0111
0112 TVal* get(const void* const key1, const int key2);
0113 const TVal* get(const void* const key1, const int key2) const;
0114
0115 MemoryManager* getMemoryManager() const;
0116 XMLSize_t getHashModulus() const;
0117
0118
0119
0120
0121 void put(void* key1, int key2, TVal* const valueToAdopt);
0122
0123 private :
0124
0125
0126
0127 friend class RefHash2KeysTableOfEnumerator<TVal, THasher>;
0128
0129
0130 private:
0131
0132
0133
0134 RefHash2KeysTableOf(const RefHash2KeysTableOf<TVal, THasher>&);
0135 RefHash2KeysTableOf<TVal>& operator=(const RefHash2KeysTableOf<TVal, THasher>&);
0136
0137
0138
0139
0140 RefHash2KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, XMLSize_t& hashVal);
0141 const RefHash2KeysTableBucketElem<TVal>* findBucketElem(const void* const key1, const int key2, XMLSize_t& hashVal) const;
0142 void initialize(const XMLSize_t modulus);
0143 void rehash();
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168 MemoryManager* fMemoryManager;
0169 bool fAdoptedElems;
0170 RefHash2KeysTableBucketElem<TVal>** fBucketList;
0171 XMLSize_t fHashModulus;
0172 XMLSize_t fCount;
0173 THasher fHasher;
0174 };
0175
0176
0177
0178
0179
0180
0181
0182 template <class TVal, class THasher>
0183 class RefHash2KeysTableOfEnumerator : public XMLEnumerator<TVal>, public XMemory
0184 {
0185 public :
0186
0187
0188
0189 RefHash2KeysTableOfEnumerator(RefHash2KeysTableOf<TVal, THasher>* const toEnum
0190 , const bool adopt = false
0191 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
0192 virtual ~RefHash2KeysTableOfEnumerator();
0193
0194
0195
0196
0197
0198 bool hasMoreElements() const;
0199 TVal& nextElement();
0200 void Reset();
0201
0202
0203
0204
0205 void nextElementKey(void*&, int&);
0206 void setPrimaryKey(const void* key);
0207
0208 private :
0209
0210
0211
0212 RefHash2KeysTableOfEnumerator(const RefHash2KeysTableOfEnumerator<TVal, THasher>&);
0213 RefHash2KeysTableOfEnumerator<TVal, THasher>& operator=(const RefHash2KeysTableOfEnumerator<TVal, THasher>&);
0214
0215
0216
0217
0218 void findNext();
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244 bool fAdopted;
0245 RefHash2KeysTableBucketElem<TVal>* fCurElem;
0246 XMLSize_t fCurHash;
0247 RefHash2KeysTableOf<TVal, THasher>* fToEnum;
0248 MemoryManager* const fMemoryManager;
0249 const void* fLockPrimaryKey;
0250 };
0251
0252 XERCES_CPP_NAMESPACE_END
0253
0254 #if !defined(XERCES_TMPLSINC)
0255 #include <xercesc/util/RefHash2KeysTableOf.c>
0256 #endif
0257
0258 #endif