What is the time complexity of std::map
问题 What is the time complexity of std::map? And will it degenerate in the worst case? Or it is decide by the implementation, we can't know it? 回答1: Lookups are proportional to log(N). In a typical case (implementation as a red-black tree) the number of comparisons can be up to twice Log 2 N. Insertions are normally proportional to Log 2 N as well--but there's a special provision made for when you're inserting a number of items that are already in order 1 . In this case, you can specify a "hint"