00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GZ_HASH_UTILS_H__
00023 #define __GZ_HASH_UTILS_H__
00024
00030 #include "gzBasicTypes.h"
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00055 class GZ_BASE_EXPORT gzInstanceCompareInterface
00056 {
00057 public:
00058
00060 gzInstanceCompareInterface() { m_address=this; }
00061
00063 gzInstanceCompareInterface(const gzVoid *address) { m_address=address; }
00064
00066 gzULong hash() const { return (gzULong)gzPtr2Val(m_address); }
00067
00069 const gzVoid * getInstance() const { return m_address; }
00070
00072 gzBool operator ==(const gzInstanceCompareInterface &right)
00073 {
00074 return (m_address == right.m_address) ;
00075 }
00076
00077 private:
00078 const gzVoid * m_address;
00079
00080 };
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00101 class GZ_BASE_EXPORT gzValueCompareInterface
00102 {
00103 public:
00104
00105 gzValueCompareInterface(const gzDouble &value)
00106 {
00107 if(((gzLongLong)value)==value)
00108 {
00109 m_union.m_value=(gzLongLong)value;
00110 m_isDouble=FALSE;
00111 }
00112 else
00113 {
00114 m_union.m_double=value;
00115 m_isDouble=TRUE;
00116 }
00117 }
00118
00119 gzULong hash() const { return (gzULong)(m_union.m_value & 0xffffffff) + (gzULong)((m_union.m_value>>32) & 0xffffffff); }
00120
00121 gzDouble getValue() const { return m_isDouble?m_union.m_double:m_union.m_value; }
00122
00123 gzBool operator ==(const gzValueCompareInterface &right)
00124 {
00125 return (m_union.m_value == right.m_union.m_value) && (m_isDouble == right.m_isDouble);
00126 }
00127
00128
00129 private:
00130
00131 union
00132 {
00133 gzLongLong m_value;
00134 gzDouble m_double;
00135 } m_union;
00136
00137 gzBool m_isDouble:1;
00138 };
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00159 class GZ_BASE_EXPORT gzULongCompareInterface
00160 {
00161 public:
00162
00163 gzULongCompareInterface(const gzULong &value):m_value(value) {}
00164
00165 gzULong hash() const { return m_value; }
00166
00167 const gzULong & getValue() const { return m_value; }
00168
00169 gzBool operator ==(const gzULongCompareInterface &right)
00170 {
00171 return (m_value == right.m_value) ;
00172 }
00173
00174
00175 private:
00176
00177 gzULong m_value;
00178 };
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00199 class GZ_BASE_EXPORT gzULongLongCompareInterface
00200 {
00201 public:
00202
00203 gzULongLongCompareInterface(const gzULongLong &value):m_value(value) {};
00204
00205 gzULong hash() const { return (gzULong)(m_value & 0xffffffff) + (gzULong)((m_value>>32) & 0xffffffff); }
00206
00207 const gzULongLong & getValue() const { return m_value; }
00208
00209 gzBool operator ==(const gzULongLongCompareInterface &right)
00210 {
00211 return (m_value == right.m_value) ;
00212 }
00213
00214
00215 private:
00216
00217 gzULongLong m_value;
00218 };
00219
00220 #endif // __GZ_HASH_UTILS_H__
00221