I need to specialize the hash function for unordered_map so I can use int arrays as keys. The array values are usually 0 or 1, e.g. int array = {0, 1, 0, 1}, but technically not bounded.
Can someone recommend a good hash function in this case? Alternatively, I can always convert the int array into a string and avoid specialization. But I am concerned about performance since I may have several million of these arrays.
C++ TR1 contains a hash template function.
If you don’t have that yet, you can use Boost Hash.
Idea for a handy helper:
This would be (roughly?) equivalent to
Don’t forget to implement proper equality comparison operations if you’re using this hash for lookup