我有兴趣找到具有两个键的地图的时间复杂度

I'm intrested in finding the time complexity of a map with two keys

我正在尝试将矩阵的整个元素转换为散列图。为此,我尝试使用 map<pair<int,int>,int>mp;

其中 pair 是数组索引,value 是矩阵元素中的值。 所以我试过这种方式 mp[{i,j}]=value;

它工作正常,但我感兴趣的是找到时间复杂度。一般来说,如果有 n 个键映射到一个值,那么时间复杂度是多少以及如何。

澄清一下,C++ 中的 map 容器是一个基于树的结构。您提到使用哈希图。 unordered_map是C++中基于散列的容器。

至于unordered_map (https://en.cppreference.com/w/cpp/container/unordered_map):

Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity.