使用C++的unordered_map类型时,我们经常要根据关键字查找,并移除一组映射,在Java中直接用remove即可,而STL中居然没有实现remove这个函数,还要自己写循环来查找要删除项,然后用erase来清除,我也是醉了,参见下面代码: vector<A*> v1; // remove A *a1 for (vector<A*>::iterator it = v1.begin(); it != v1.end(); ++it) { if (*it == a1) v1.er
hash_map vs unordered_map 这两个的内部结构都是采用哈希表来实现.unordered_map在C++11的时候被引入标准库了,而hash_map没有,所以建议还是使用unordered_map比较好. unordered_map vs map map的内部结构是R-B-tree来实现的,所以保证了一个稳定的动态操作时间,查询.插入.删除都是O(logN),最坏和平均情况都是:而unordered_map是哈希表.虽然哈希表的查询时间是O(1),但是并不是unordered
I decide to write to my blogs in English. When I meet something hard to depict, I'll add some Chinese necessarily. The differences between these containers are : The keys of set and map are unique, but they could be multiple for multiset and multimap