I need to implement a set of sets in my application.
Using QSet with a custom class requires providing a qHash()
function and an operator==
.
The code is as follows:
class Custom{
int x;
int y;
//some other irrelevant here
}
inline uint qHash(Custom* c){
return (qHash(c->x) ^ qHash(c->y));
}
bool operator==(Custom &c1, Custom &c2){
return ((c1.x==c2.x) && (c1.y == c2.y));
}
//now I can use: QSet<Custom*>
How can I implement qHash(QSet<Custom*>)
, to be able to use QSet< QSet<SomeClass*> >
?
Edit:
Additional question:
In my application the "set of sets" can contain up to 15000 sets. Each subset up to 25 Custom class pointers. How to guarantee that qHash(QSet<Custom*>)
will be unique enough?