Boost.unordered implements more than four containers on the basis of the C + + standard container std::set,std::multiset,std::map and Std::multimap: boost::unordered_set,boost:: Unordered_multiset,boost::unordered_map and Boost::unordered_multimap. There is no difference between the containers whose names are very similar, and even the same interfaces are provided. In many cases, replacing these two containers (STD and boost) will have no effect on your application.
Summary: It is inside the library and the original C + + standard library map, set and so on, but the internal data structure to red black tree for the implementation of the hash table, although it will increase the storage space of the object, but the average complexity of the search from O (logn) into O (1), greatly improve the search efficiency. It's an excellent choice for applications that need frequent index lookups (and of course you need to consider cost-effectiveness, mostly storage space).
1#include <iostream>2#include <boost/unordered_set.hpp>3 4 voidMain ()5 {6BOOST::UNORDERED_SET<STD::string>Myhashset;7 8Myhashset.insert ("ABC");9Myhashset.insert ("DEF");TenMyhashset.insert ("GHI"); One A for(Auto IB = Myhashset.begin (); IB! = Myhashset.end (); ib++) - { -Std::cout << *ib <<Std::endl; the } - -Std::cout << (Myhashset.find ("GHI")! = Myhashset.end ()) << Std::endl;//Returns 1 if the lookup succeeds, otherwise returns 0 -}
#include <boost/unordered_set.hpp>