bool operator==(const MyStructType& n) { if(n.a != a || n.b!= b || n.c != c) return false; return true; }
struct MyStructType{ qint32 x; qint32 y; qint32 z; bool operator==(const MyStructType &key) { if(key.x != x || key.y!= y || key.z != z) return false; return true; }};inline uint qHash(const MyStructType &key){ return qHash( key.x ) ^ qHash( key.y ) ^ qHash( key.z );}int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); QHash<MyStructType, QString> tileNodeCache; MyStructType myStruct; myStruct.x = 1; myStruct.y = 2; myStruct.z = 3; tileNodeCache.insert(myStruct, "test"); tileNodeCache[myStruct] = "test"; return a.exec();}
class NewHashClass{public: NewHashClass(const int value1,const int value2,const int value3): value1(value1), value2(value2), value3(value2) {} int getValue() const { return qHash(value1) ^ qHash( value2 ) ^ qHash( value3 ); }//private: int value1; int value2; int value3;};bool operator==(const NewHashClass &b1, const NewHashClass &b2){ return (b1.value1 == b2.value1 && b1.value2 == b2.value2 && b1.value3 == b2.value3);}uint qHash(const NewHashClass &key){ return qHash(key.value1) ^ qHash( key.value2 ) ^ qHash( key.value3 );}