00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 #if !defined(VALUEHASHTABLEOF_HPP)
00063 #define VALUEHASHTABLEOF_HPP
00064
00065
00066 #include <xercesc/util/XercesDefs.hpp>
00067 #include <xercesc/util/HashBase.hpp>
00068 #include <xercesc/util/IllegalArgumentException.hpp>
00069 #include <xercesc/util/NoSuchElementException.hpp>
00070 #include <xercesc/util/RuntimeException.hpp>
00071 #include <xercesc/util/XMLExceptMsgs.hpp>
00072 #include <xercesc/util/XMLEnumerator.hpp>
00073 #include <xercesc/util/XMLString.hpp>
00074 #include <xercesc/util/HashBase.hpp>
00075 #include <xercesc/util/HashXMLCh.hpp>
00076
00077
00078
00079
00080
00081
00082 template <class TVal> class ValueHashTableOfEnumerator;
00083 template <class TVal> struct ValueHashTableBucketElem;
00084
00085
00086
00087
00088
00089
00090 template <class TVal> struct ValueHashTableBucketElem
00091 {
00092 ValueHashTableBucketElem(void* key, const TVal& value, ValueHashTableBucketElem<TVal>* next)
00093 : fData(value), fNext(next), fKey(key)
00094 {
00095 }
00096
00097 TVal fData;
00098 ValueHashTableBucketElem<TVal>* fNext;
00099 void* fKey;
00100 };
00101
00102
00103 template <class TVal> class ValueHashTableOf
00104 {
00105 public:
00106
00107
00108
00109
00110 ValueHashTableOf(const unsigned int modulus);
00111
00112
00113
00114 ValueHashTableOf(const unsigned int modulus, HashBase* hashBase);
00115 ~ValueHashTableOf();
00116
00117
00118
00119
00120
00121 bool isEmpty() const;
00122 bool containsKey(const void* const key) const;
00123 void removeKey(const void* const key);
00124 void removeAll();
00125
00126
00127
00128
00129
00130 TVal& get(const void* const key);
00131 const TVal& get(const void* const key) const;
00132
00133
00134
00135
00136
00137 void put(void* key, const TVal& valueToAdopt);
00138
00139
00140 private :
00141
00142
00143
00144 friend class ValueHashTableOfEnumerator<TVal>;
00145
00146 private:
00147
00148
00149
00150
00151 ValueHashTableBucketElem<TVal>* findBucketElem(const void* const key, unsigned int& hashVal);
00152 const ValueHashTableBucketElem<TVal>* findBucketElem(const void* const key, unsigned int& hashVal) const;
00153 void removeBucketElem(const void* const key, unsigned int& hashVal);
00154 void initialize(const unsigned int modulus);
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 ValueHashTableBucketElem<TVal>** fBucketList;
00172 unsigned int fHashModulus;
00173 HashBase* fHash;
00174 };
00175
00176
00177
00178
00179
00180
00181
00182 template <class TVal> class ValueHashTableOfEnumerator : public XMLEnumerator<TVal>
00183 {
00184 public :
00185
00186
00187
00188 ValueHashTableOfEnumerator(ValueHashTableOf<TVal>* const toEnum, const bool adopt = false);
00189 ~ValueHashTableOfEnumerator();
00190
00191
00192
00193
00194
00195 bool hasMoreElements() const;
00196 TVal& nextElement();
00197 void Reset();
00198
00199
00200 private :
00201
00202
00203
00204 void findNext();
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 bool fAdopted;
00226 ValueHashTableBucketElem<TVal>* fCurElem;
00227 unsigned int fCurHash;
00228 ValueHashTableOf<TVal>* fToEnum;
00229 };
00230
00231 #if !defined(XERCES_TMPLSINC)
00232 #include <xercesc/util/ValueHashTableOf.c>
00233 #endif
00234
00235 #endif