forget about the hash; there is nothing (at least from your question) that suggests that you have a meaningful key;
lets you step back and rephrase your actual performance:
- you want to quickly check for duplicates for any object objects
comment if I need to add others.
From the above goal, and from your comment, I would suggest using ordered_set , not unordered_map. Yes, an ordered search uses the binary search O (log (n)), while an unordered one uses the search O (1).
However, the difference is that with this approach, you need an ordered_component ONLY to verify that such a state does not exist already when you are going to create a new one, that is, it is in a time creation state.
In all other search queries, you actually don't need to look into order_set! because you already have a key; State *, and the key can access the value using the magic dereference operator: * key
so with this approach, you only use order_set as index to check the states when creating only time. In all other cases, you get access to your state using the pointer key dereference operator.
if all of the above was not enough to convince you, here is the last nail in the coffin of the idea to use a hash to quickly determine equality; the hash function has a small probability of collision, but as the number of states increases, this probability will become a complete certainty. Therefore, depending on your resiliency, you will be dealing with government clashes (and from your question and the number of states that you expect to deal with, it looks like you will be dealing with a lot of them).
To do this, you obviously need a comparison predicate to check all the internal properties of your state (gyroscope, motors, accelerometers, proton rays, etc.).