unordered_set
, unordered_map
, unordered_multiset
, unordered_multimap
. Each of these containers differ only on constraints placed on their elements.
The unordered associative containers are similar to the History
The first widely used implementation of hash tables in the C++ language washash_map
, hash_set
, hash_multimap
, hash_multiset
class templates of the Silicon Graphics (SGI) Standard Template Library (STL). Due to their usefulness, they were later included in several other implementations of the C++ Standard Library (e.g., the GNU Compiler Collection's (GCC) libstdc++ and the Visual C++ (MSVC) standard library).
The hash_*
class templates were proposed into C++ Technical Report 1 (C++ TR1) and were accepted under names unordered_*
. Later, they were incorporated into the C++11 revision of the C++ standard. An implementation is also available in the Boost C++ Libraries as
.
Overview of functions
The containers are defined in headers named after the names of the containers, e.g.,unordered_set
is defined in header
. All containers satisfy the requirements of thbegin()
, end()
, size()
, max_size()
, empty()
, and swap()
methods.
Usage example
Custom hash functions
To use custom objects in std::unordered_map, a custom hash function must be defined. This function takes a const reference to the custom type and returns a size_tReferences
{{use dmy dates, date=January 2012 Articles with example C++ code C++ Standard Library