From: <mk...@us...> - 2003-01-20 23:06:53
|
Update of /cvsroot/csp/APPLICATIONS/SimData/Include/SimData In directory sc8-pr-cvs1:/tmp/cvs-serv26134/Include/SimData Modified Files: Tag: simdata HashUtility.h HashUtility.i Log Message: more hasht fixes Index: HashUtility.h =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Attic/HashUtility.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** HashUtility.h 20 Jan 2003 05:53:12 -0000 1.1.2.4 --- HashUtility.h 20 Jan 2003 23:06:47 -0000 1.1.2.5 *************** *** 29,32 **** --- 29,33 ---- #define __HASHUTILITY_H__ + #include <iostream> #include <SimData/hash_map.h> #include <SimData/GlibCsp.h> *************** *** 39,63 **** ! #define hashstr4 newhash4_cstring ! #define hashstr8 newhash8_cstring // use 64-bit hash values - #define hash_string hashstr8 //#define hasht u8 ! #define hasht_hash hashu8 ! #define hasht_eq equ8 typedef guint32 u4; /* unsigned 4-byte type */ typedef guint8 u1; /* unsigned 1-byte type */ typedef guint64 u8; /* unsigned 8-byte type */ ! typedef u8 hasht; NAMESPACE_SIMDATA ! typedef u8 hasht; extern u4 newhash4_cstring(const char*); ! extern u8 newhash8_cstring(const char*); --- 40,103 ---- ! //#define hashstr4 newhash4_cstring ! //#define hashstr8 newhash8_cstring // use 64-bit hash values //#define hasht u8 ! #define hash_string newhasht_cstring ! //#define hash_string hashstr8 ! //#define hasht_hash hashu8 ! //#define hasht_eq equ8 typedef guint32 u4; /* unsigned 4-byte type */ typedef guint8 u1; /* unsigned 1-byte type */ typedef guint64 u8; /* unsigned 8-byte type */ ! //typedef u8 hasht; ! NAMESPACE_SIMDATA ! //typedef u8 hasht; ! struct HashT { ! guint32 a, b; ! HashT() { ! a = b = 0; ! } ! HashT(guint32 x) { ! a = x; b = 0; ! } ! HashT(guint32 b_, guint32 a_) { ! a = a_; b = b_; ! } ! HashT(const HashT &x) { ! a = x.a; b = x.b; ! } ! bool operator ==(guint32 x) const { ! return (b == 0 && a == x); ! } ! bool operator !=(guint32 x) const { ! return (b != 0 || a != x); ! } ! bool operator ==(HashT const &x) const { ! return (b == x.b && a == x.a); ! } ! bool operator !=(HashT const &x) const { ! return (b != x.b || a != x.a); ! } ! void operator =(guint32 x) { ! a = x; b = 0; ! } ! void operator =(HashT const &x) { ! a = x.a; b = x.b; ! } ! }; ! ! typedef HashT hasht; ! extern u4 newhash4_cstring(const char*); ! extern hasht newhasht_cstring(const char*); ! //extern u8 newhash8_cstring(const char*); *************** *** 80,83 **** --- 120,137 ---- }; + + struct hasht_eq { + bool operator()(hasht i1, hasht i2) const { + return ((i1.a == i2.a) && (i1.b == i2.b)); + } + }; + + struct hasht_hash { + bool operator()(hasht i1) const { + return i1.a; + } + }; + + /* struct equ8 { bool operator()(u8 i1, u8 i2) const { *************** *** 91,94 **** --- 145,149 ---- } }; + */ typedef HASH_MAP<hasht, int, hasht_hash, hasht_eq> hasht_map; *************** *** 102,105 **** --- 157,167 ---- NAMESPACE_END // namespace simdata + + + typedef SIMDATA(HashT) hasht; + + extern std::ostream & operator<<(std::ostream &o, const hasht &x); + + #endif // __HASHUTILITY_H__ Index: HashUtility.i =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/SimData/Include/SimData/Attic/HashUtility.i,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** HashUtility.i 19 Jan 2003 20:28:29 -0000 1.1.2.1 --- HashUtility.i 20 Jan 2003 23:06:48 -0000 1.1.2.2 *************** *** 8,18 **** typedef unsigned long int u4; /* unsigned 4-byte type */ typedef unsigned char u1; /* unsigned 1-byte type */ - typedef unsigned long long u8; /* unsigned 8-byte type */ ! %rename(hash_string) SIMDATA(newhash8_cstring)(const char*); NAMESPACE_SIMDATA u4 newhash4_cstring(const char*); ! u8 newhash8_cstring(const char*); NAMESPACE_END --- 8,51 ---- typedef unsigned long int u4; /* unsigned 4-byte type */ typedef unsigned char u1; /* unsigned 1-byte type */ ! /* typedef unsigned long long u8; /* unsigned 8-byte type */ ! ! %rename(hash_string) SIMDATA(newhasht_cstring)(const char*); NAMESPACE_SIMDATA + + struct HashT { + guint32 a, b; + HashT() { + a = b = 0; + } + HashT(guint32 x) { + a = x; b = 0; + } + HashT(guint32 b_, guint32 a_) { + a = a_; b = b_; + } + HashT(const HashT &x) { + a = x.a; b = x.b; + } + bool operator ==(guint32 x) const { + return (b == 0 && a == x); + } + bool operator !=(guint32 x) const { + return (b != 0 || a != x); + } + bool operator ==(HashT const &x) const { + return (b == x.b && a == x.a); + } + bool operator !=(HashT const &x) const { + return (b != x.b || a != x.a); + } + }; + + typedef HashT hasht; + + u4 newhash4_cstring(const char*); ! HashT newhasht_cstring(const char*); NAMESPACE_END |