摘要:Google HashMap : sparsehash
Performance Benchmark
- Hash Table Benchmarks
- Hash Table Performance Tests
- Benchmarks: Std::tr1::unordered_map Vs Boost::unordered_map Vs Std::map
使用方法
- dense_hash_map的复杂key的用法
- C++: hashtable - Why won't this compile?
- Unordered Map With Custom Structures
- dense_hash_map<Key, Data, HashFcn, EqualKey, Alloc>
- unordered_map hash function c++
Hash Function
Note
- Insert 前要呼叫 set_empty_key function
- Erase 前要呼叫 set_deleted_key function
-
若欲 Insert 的 key 為自訂型別,要提供 hash function 及 equal function
class pairHashTri{ public: size_t operator()(const std::pair<std::pair<int,int>,int> &k) { return k.first.first * 100 + k.first.second * 10 + k.second; } }; struct eqstr { bool operator()(CLMEntry &s1, CLMEntry &s2) const { return (s1.fBackoff == s2.fBackoff && s1.fProb == s2.fProb); } }; google::dense_hash_map<std::pair<std::pair<int,int>,int>, CLMEntry, pairHashTri> mapTrigram;