
std
文章平均质量分 55
bai_lu_sz
这个作者很懒,什么都没留下…
展开
-
hash_map和map的区别
这里列几个常见问题,应该对你理解和使用hash_map比较有帮助。 4.1 hash_map和map的区别在哪里? 构造函数。hash_map需要hash函数,等于函数;map只需要比较函数(小于函数). 存储结构。hash_map采用hash表存储,map一般采用红黑树(RB Tree)实现。因此其memory数据结构是不一样的。 4.2 什么时候需要用hash_map,什么转载 2012-12-17 20:03:04 · 766 阅读 · 0 评论 -
std::hash_multimap 遍历同一key下的不同value
直接贴代码 #include #include #include using namespace stdext; using namespace std; int main() { hash_multimap hm1; hm1.insert(pair(1, "hello")); hm1.insert(pair(1, "hellos")); hm1.ins原创 2012-12-18 09:29:43 · 2201 阅读 · 0 评论 -
关联容器
http://blog.youkuaiyun.com/wangxu_zju_2010/article/details/7588805 关联容器: 利用键,STL的关联容器能直接保存和提取键。 4个关联容器分别为:multiset,set,multimap,map。每个关联容器都按有序的方式维护者它的键。对关联容器的迭代遍历是根据这个容器的排序顺序进行的。 multise转载 2012-12-20 17:26:33 · 700 阅读 · 0 评论 -
std::list 错误使用的地方
struct bbbbb { list aaa; bbbbb() { memset(this, 0, sizeof (bbbbb)); } }; bbbbb a; a.aaa.clear(); 这样会出错 有知道原因的 贴一下 让我学习学习原创 2012-11-30 15:14:23 · 858 阅读 · 0 评论 -
std 节点型容器遍历要注意 list iterator not incrementable
for (; it != list_time.end();) { if (*it { it = list_time.erase(it); } else { ++it; } } 下面是几个好的博客文章: http://write.blog.youkuaiyun.com/postedit http:/原创 2012-11-24 13:00:34 · 924 阅读 · 1 评论 -
for_each使用方法详解[转]
Abstract 之前在(原創) 如何使用for_each() algorithm? (C/C++) (STL) 曾經討論過for_each(),不過當時功力尚淺,只談到了皮毛而已,這次看了effective STL的item 41、43後,對for_each()又有了更深入的了解,因此做了本篇心得報告。 Motivation 看到了eXile的C++中实现 foreach使用了巨集转载 2013-03-18 18:03:50 · 986 阅读 · 0 评论 -
(转)解析bind1st和bind2nd的使用
1、首先看一个容器的操作: void f(std::vector &vect) { std::vector::iterator firstOne; for (firstOne = vect.begin(); firstOne != vect.end(); ++firstOne) { doSomething(*f转载 2013-03-18 18:04:22 · 978 阅读 · 0 评论