天天看點

map和hash_map的差別include //mapinclude <hash_map>

1、STL的map底層是用紅黑樹(RB Tree)實作的,查找時間複雜度是log(n),而hash_map底層是用hash表存儲的,查詢時間複雜度是O(1)

2、hash_map比map查找速度更快。

3、linux c的使用方法

include //map

using namespace std;//make_pair需要

include <hash_map>

using namespace __gnu_cxx;//hash_map是聲明在__gnu_cxx命名空間的

typedef hash_map<int, CNet_TCPConn*> TCPConnMap_t;

TCPConnMap_t m_map;

繼續閱讀