| morando (127) | |||
|
This is gonna be hard to explain. I am learning to use some physics library. I need a unique pairs of "materials" in some container and be able to get its "interaction" value. So i thought to use unordered_map:
I am worried about hash function witch i used from WIKI article. Am i guaranteed a unique pairs with this? Or you have better idea? Thank you for your time. | |||
|
|
|||
| JLBorges (1754) | |||
> Or you have better idea?boost::hash_combine()
| |||
|
|
|||
| morando (127) | |
|
Looks like seed for hash combine must be in same order, i need hash function for pair of ints such that : pair(EMT_WOOD, EMT_METAL) == pair(EMT_METAL, EMT_WOOD) and can be same, for example: pair(EMT_WOOD, EMT_WOOD), if that is relevant. | |
|
|
|
| JLBorges (1754) | |||
|
> i need hash function for pair of ints such that : > pair(EMT_WOOD, EMT_METAL) == pair(EMT_METAL, EMT_WOOD) Then the hash function needs to be symmetric. XOR is symmetric, but it can generate a large number of collisions. Perhaps something like this:
| |||
|
|
|||