刚知道原来map和unordered_map的实现方式不同,前者用的红黑树,后者用的哈希表
所以就想看下系统中map和unordered_map源码的实现方式
当我命令行中输入` find / | grep unordered_map` 时,出现了两个相同的文件:
**
/usr/include/c++/5.1.0/bits/unordered_map.h
/usr/include/c++/5.1.0/tr1/unordered_map.h
**
分别放在bits和tr1目录中,然后就google下这两个目录的区别:
这是stackoverflow上对bits目录的解释:
>The official designation of that folder according to the libstdc++ documentation is:
>
>"Files included by standard headers and by other files in the bits directory"
>Where "bits" probably just means something trivial as "the bits that make up the implementation of >what you include via the standard headers".
>For example, if you include the standard <algorithm> header, you really include bits/c++config.h, >bits/stl_relops.h, bits/stl_pair.h bits/stl_algobase.h and bits/stl_algo.h under the hood, each of >which defines the odd bits that alltogether give you what someone including <algorithm> would >expect to get.
Boost calls the conceptually same folder "detail".
====
但是对于上面的解释,自己表示没怎么理解,所以想来这里问下各位!!!
所以就想看下系统中map和unordered_map源码的实现方式
当我命令行中输入` find / | grep unordered_map` 时,出现了两个相同的文件:
**
/usr/include/c++/5.1.0/bits/unordered_map.h
/usr/include/c++/5.1.0/tr1/unordered_map.h
**
分别放在bits和tr1目录中,然后就google下这两个目录的区别:
这是stackoverflow上对bits目录的解释:
>The official designation of that folder according to the libstdc++ documentation is:
>
>"Files included by standard headers and by other files in the bits directory"
>Where "bits" probably just means something trivial as "the bits that make up the implementation of >what you include via the standard headers".
>For example, if you include the standard <algorithm> header, you really include bits/c++config.h, >bits/stl_relops.h, bits/stl_pair.h bits/stl_algobase.h and bits/stl_algo.h under the hood, each of >which defines the odd bits that alltogether give you what someone including <algorithm> would >expect to get.
Boost calls the conceptually same folder "detail".
====
但是对于上面的解释,自己表示没怎么理解,所以想来这里问下各位!!!