2011年9月25日

HashMap<string, ...> 能有多快

摘要: 看到很多使用 map 的代码, 也有一些使用了 unordered_map 或者 hash_map, 当然, hash_map 不是标准的, unordered_map 也只在 boost, tr1 和 c++0x 中可用. 从代码的简洁性和可移植性上讲, 标准的 std::map 是首选.然而, 从另一方面看, gcc 的 string 是 refcounted & copy on write 的, 64 位环境下, 一个 string 的额外开销是 32 字节, 如果加上 string 内容的额外对齐(8 byte align)开销, 则上升到平均至少 36 字节. 所以哪怕我的 阅读全文

posted @ 2011-09-25 12:56 能发波 阅读(303) 评论(0) 推荐(0)

导航