I was reading over my text book Data Structures and Algorithms: By Mark Allen Weiss and it says that the standard library does not contain hash table implementations of a set or map, but rather compilers can provide hash_set and hash_map with same member functions of the set and map class. Why not just include hash implementations in the standard library? The book was published in 2006, have there been any revisions of C++ since to add these implementations to the standard library?
I was reading over my text book Data Structures and Algorithms: By Mark Allen
Share
What you’re looking for are called
std::unordered_set/map. These are part of C++11, the next version of the C++ standard (due to be finalized in a few months). They were also made available in Technical Report 1 in 2005, which was a list of additions to the C++ standard library between the first standard and the next one. In TR1, they were in thestd::tr1namespace.Boost actually ships an implementation of TR1 (though you shouldn’t use the
std::tr1::shared_ptrversion, as the regularboost::shared_ptrandstd::shared_ptrin C++11 are much, much better).If I recall, the reason why hash tables were not initially introduced in C++98 was simply a lack of time for the C++ standards committee. They basically had a cut-off date in order to ship the thing, and hash tables didn’t make it.