I understand that unordered_map<T, int>
would be more efficient when retrieving a value from the key O(1), than map<T, int>
would be O(lg n) regarding the performance.
However, I found that unordered_map<T, int>
does not support as many types as map<T, int>
does.
For instance, map<pair<int, int>, int>
is OK, but unordered_map<pair<int, int>, int>
is not.
I am wondering is there any underlying difficulty for this? If the performance is concerned, what data structure could I use to get a hashtable of key-type pair with O(1) performance.