#include <boost/unordered_set.hpp>

Source: Internet
Author: User

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&LT;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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.