-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Expert C++ - Second Edition
By :
In the previous chapter, we discussed std::unordered_map very briefly, saying only that it is the representation of the hash table data structure in C++. At first, along with other hash containers, std::unordered_map wasn’t in the original STL. It was introduced to C++ users only with the TR1 library extension.
std::unordered_map is an associative container that is part of the STL library. It holds key-value pairs with distinctive keys. The time complexity of search, insertion, and removal of items is amortized O(1). This means that all the operations listed are performed in a constant time almost always. In an unordered map, the key value often serves as a means of uniquely identifying each element, and the mapped value is an object connected to that key. Key-value and mapped value types may vary.
Internally, the components are arranged into buckets rather than being sorted in any specific sequence. The hash of an element&...