std::map
suggest changeRemarks
- Include
<map>to usestd::maporstd::multimap. - Both containers keep their elements ordered according to a comparison function, which uses ascending key order by default. Elements with equivalent keys in a
std::multimapretain their relative insertion order. std::mapstores at most one element for each key.std::multimappermits multiple elements with equivalent keys.- Search, insertion, and erasure have logarithmic complexity. Implementations commonly use balanced search trees, although the standard does not require a particular data structure.
size()andempty()have constant complexity.std::unordered_mapprovides average constant-time lookup, but its worst-case lookup complexity is linear and it does not maintain key order.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents