爲什麼Google sparsehash開源庫有兩個實現:密集的哈希表和稀疏的哈希表?稀疏散列表背後的主要實現思路是什麼?
17
A
回答
16
密集的散列表是您的普通教科書散列表實現。
稀疏散列表僅存儲實際設置的元素,並將其劃分爲多個數組。從comments在稀疏表的實施引證:
// The idea is that a table with (logically) t buckets is divided
// into t/M *groups* of M buckets each. (M is a constant set in
// GROUP_SIZE for efficiency.) Each group is stored sparsely.
// Thus, inserting into the table causes some array to grow, which is
// slow but still constant time. Lookup involves doing a
// logical-position-to-sparse-position lookup, which is also slow but
// constant time. The larger M is, the slower these operations are
// but the less overhead (slightly).
到知道該陣列的元素被設置,一個稀疏表包括位圖:
// To store the sparse array, we store a bitmap B, where B[i] = 1 iff
// bucket i is non-empty. Then to look up bucket i we really look up
// array[# of 1s before i in B]. This is constant time for fixed M.
,使得每個元件招致的開銷只有1位(在限制內)。
3
sparsehash是將鍵映射到值(每個鍵1-2位)的高效內存方式。布隆過濾器可以爲每個關鍵點提供更少的位數,但它們除了外部/可能位於內部之外不會將值附加到鍵以外,這比稍微少於一點的信息要少。
相關問題
- 1. scipy中的這個稀疏矩陣是什麼意思?
- 2. 稀疏實現/ scikit學習
- 3. 實現是什麼意思?
- 4. 稀疏矢量,它們是什麼?
- 5. 稀疏矩陣的pLSA實現
- 6. '散列缺點'是什麼意思?
- 7. Bash'type someCmd':什麼意思是'散列'?
- 8. 在稀疏表
- 9. 從稀疏矢量列表創建稀疏矩陣
- 10. 「散貨」是什麼意思?
- 11. 使用稀疏列而不是普通關係表的風險是什麼?
- 12. 三維稀疏矩陣實現?
- 13. 稀疏束調整實現c/C++
- 14. 如何在稀疏的事實表
- 15. Java的實現是什麼意思?
- 16. .js文件後散列(#)是什麼意思?
- 17. 是稀疏數據
- 18. node.js實現背後的基本思想?
- 19. .NET庫中是否有稀疏的數組實現?
- 20. 稀疏矩陣的列聯表
- 21. 的Fortran:稀疏數組或列表
- 22. 稀疏矩陣的向量列表
- 23. 實現3維稀疏表的構造函數
- 24. 實體框架與稀疏表
- 25. 稀疏列或普通列?
- 26. Oracle中的稀疏列
- 27. 「期望的主要表達式__」是什麼意思?
- 28. 如何使用谷歌的稀疏散列
- 29. 矩陣稀疏模式的合適散列函數
- 30. 爲什麼程序想要/更喜歡使用稀疏文件?
我想我誤解了帖子中的問題。不會稀疏哈希表+密集哈希表==所有哈希表?如果是這樣,那麼爲什麼圖書館稱爲「sparsehash」? – cHao 2011-03-13 12:22:38
BTW:[來自Google代碼的文檔](http://google-sparsehash.googlecode.com/svn/trunk/doc/implementation.html)。 – cHao 2011-03-13 12:28:24