简体   繁体   中英

Google dense_hash_map C++

So, I'm trying to implement a map that will have probably around 20,000 String, String pairs in C++. Is it worth it to use Google Dense Hash Map? I will be mainly checking the map for the pair and inserting it if not found. I wont be making any deletions or alterations to the pairs. If I should use dense hash map, how do I? There is not much information online but I know I need a hash function.

EDIT: they are String to String pairs

If you need a hash map to be faster and have a bit of spare memory then go for it.

Google dense map is easy to install ( aptitude install libsparsehash-dev on Debian ) and it is header-only so you don't even need to link to another library. It is a fastest hash map around, but has higher memory requirements than other maps.

http://incise.org/hash-table-benchmarks.html benchmark has a good comparison of performance and memory profiles (here's the raw results of that benchmark from 2013-08-02: http://pastebin.com/jJL3rzWp ).

Note, that for some loads a b+tree can me more cache-friendly than a hash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM