unordered_set - AstroMen/Algorithm-DataStructure GitHub Wiki
unordered_set<int> m(nums1.begin(), nums1.end());
` int main ()
{
std::unordered_setstd::string first; // empty
std::unordered_setstd::string second ( {"red","green","blue"} ); // init list
std::unordered_setstd::string third ( {"orange","pink","yellow"} ); // init list
std::unordered_setstd::string fourth ( second ); // copy
std::unordered_setstd::string fifth ( cmerge(third,fourth) ); // move
std::unordered_setstd::string sixth ( fifth.begin(), fifth.end() ); // range
std::cout << "sixth contains:";
for (const std::string& x: sixth) std::cout << " " << x;
std::cout << std::endl;
return 0;
} `
Possible output:
sixth contains: pink yellow red green orange blue
empty,size,max_size
` int main ()
{
std::unordered_setstd::string myset;
std::cout << "0. size: " << myset.size() << std::endl;
myset = {"milk","potatoes","eggs"};
std::cout << "1. size: " << myset.size() << std::endl;
myset.insert ("pineapple");
std::cout << "2. size: " << myset.size() << std::endl;
myset.erase ("milk");
std::cout << "3. size: " << myset.size() << std::endl;
return 0;
} `
Output:
0. size: 0
- size: 3
- size: 4
- size: 3
begin, end, cbegin, cend
find, count, equal_range
emplace, insert, erase, clear, swap
reverse