std::map
suggest changeRemarks
- To use any of
std::maporstd::multimapthe header file<map>should be included. std::mapandstd::multimapboth keep their elements sorted according to the ascending order of keys. In case ofstd::multimap, no sorting occurs for the values of the same key.- The basic difference between
std::mapandstd::multimapis that thestd::mapone does not allow duplicate values for the same key wherestd::multimapdoes. - Maps are implemented as binary search trees. So
search(),insert(),erase()takes Θ(log n) time in average. For constant time operation usestd::unordered_map. size()andempty()functions have Θ(1) time complexity, number of nodes is cached to avoid walking through tree each time these functions are called.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents