-
Notifications
You must be signed in to change notification settings - Fork 0
unordered_set
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
STL
标准STL序列容器
* vector
* string
* deque
* list
标准STL Associative Container
* set
* multiset
* map
* multimap
非标准关联容器
* hash_set
* hash_multiset
* hash_map
* hash_multimap
* unordered_set
* unordered_multiset
* unordered_map
标准非STL容器
* array
* stack
* queue
* hash_multimap
数据结构的对比
常见面试题
面试题词汇
TopK
5亿个int找中位数
多线程-生产者消费者模式
Suggestion
* Suggestion for job