Currently the most widely used collection of collections in C ++

I am looking for a set of containers in C ++. I want something where I could add elements, but they would not be repeated more than once, and the search in this collection would be O (1). For this, the container for the defacto cross-compiler is now used. I saw some in boost (e.g. mpl), and there is one in the future C ++ standards, but what is the best use now and here?

EDIT

An example of saving a vector in a boost :: unordered_set container. So for me it seems to fit my needs, but I will have a lot of data, so if someone immediately sees some potential error, you can comment on what could go wrong. Again, all elements will be sorted by vector without pointers.

vector<string> values1;
values1.push_back("aaa");
values1.push_back("bbb");
values1.push_back("ccc");

vector<string> values2;
values2.push_back("aa");
values2.push_back("bbb");
values2.push_back("ccc");

vector<string> values3;
values3.push_back("aaa");
values3.push_back("bbb");

vector<string> values4;
values4.push_back("aaa");
values4.push_back("bbb");
values4.push_back("ccc");
values4.push_back("ddd");

vector<string> values5;
values5.push_back("aaa");
values5.push_back("bbb");
values5.push_back("ccc");


vector<string> values6;
values6.push_back("aaa");
values6.push_back("bbb");
values6.push_back("ccc");
values6.push_back("ddd");

boost::unordered_set<vector<string> > collection;
collection.insert(values1); // 1
cout << collection.size() << endl;
collection.insert(values2); // 2
cout << collection.size() << endl;
collection.insert(values3); // 3
cout << collection.size() << endl;
collection.insert(values4); // 4
cout << collection.size() << endl;
collection.insert(values5); // 4
cout << collection.size() << endl;
collection.insert(values6); // 4
cout << collection.size() << endl;
+3
4

std:: unordered_set, ++ 0x , .

, Microsoft V++ stdext:: hash_set boost:: unordered_set. - , ++ 0x. @Nemo, Boost std::tr1::unordered_set.

[std::set O (log n), . O (1), - - -.]

+8

++ 03: boost::unordered_set

++ 0x: std::unordered_set

(stdext::hash_set V++) -.

. boost::unordered_set std::unordered_set, .

: == > - , , Bloom Filters.

+4

, -, O (1) (.. ), std::unordered_set / boost::unordered_set. ++ 03 std::set std::multiset RB , , O (log n).

+1
source

You can also look at the HashSet class from Poco C ++ .

0
source

All Articles