問題描述
我需要將原始鍵(int,可能是 long)映射到高性能哈希映射數據結構中的結構值.
I need to map primitive keys (int, maybe long) to struct values in a high-performance hash map data structure.
我的程序會有幾百張這樣的地圖,而每張地圖一般最多只有幾千個條目.但是,地圖會不斷刷新"或攪動";想象一下,每秒處理數百萬條 add
和 delete
消息.
My program will have a few hundred of these maps, and each map will generally have at most a few thousand entries. However, the maps will be "refreshing" or "churning" constantly; imagine processing millions of add
and delete
messages a second.
C 或 C++ 中的哪些庫具有適合此用例的數據結構?或者,您會如何推薦自己構建?謝謝!
What libraries in C or C++ have a data structure that fits this use case? Or, how would you recommend building your own? Thanks!
推薦答案
我建議你試試 Google SparseHash(或 C11 版本 Google SparseHash-c11)并查看它是否適合您的需求.它們具有內存高效的實現方式以及針對速度進行了優化的實現方式.我很久以前做過一個基準測試,它是速度方面最好的哈希表實現(但也有缺點).
I would recommend you to try Google SparseHash (or the C11 version Google SparseHash-c11) and see if it suits your needs. They have a memory efficient implementation as well as one optimized for speed. I did a benchmark a long time ago, it was the best hashtable implementation available in terms of speed (however with drawbacks).
這篇關于超高性能C/C++哈希映射(表、字典)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!