I chose the concept of hash tables in Java, so I knew that for a universal hash set container for custom classes, you had to provide a definition of the hash function and the corresponding equality function.
In Java, this would mean an overriding method.
int hashCode()
and
boolean equals (Object o)
.
I expected the same logic in the C ++ STL, but had difficulty understanding the syntax. In particular, std :: unordered_set <> takes 5 arguments to the template (can you believe it?), Which looks like a monster and makes my head spin.
So, I would appreciate it if you could give a simple example for the current class of toys:
class Some{ public : int a; };
The a value is simply returned from the hash function, and the equality checking functions return true if the values โโof the 'a' member are the same.
thanks
source share