sparsehash

How does google's sparse hash table handle collisions?

房东的猫 提交于 2019-12-23 03:27:14
问题 How does google's sparse hash table handle collisions? i.e. when 2 elements map to the same bucket, how does it decide where to put the new (colliding) element? I'm reading What is the main implementation idea behind sparse hash table? but that answer doesn't cover the collision idea. 回答1: Your question is answered in the documentation here, specifically: 2c) If t.sparsetable[i % 32] is assigned, but to a value other than foo, look at t.sparsetable[(i+1) % 32] . If that also fails, try t

What is the main implementation idea behind sparse hash table?

北战南征 提交于 2019-12-04 15:53:34
问题 Why does Google sparsehash open-source library has two implementations: a dense hashtable and a sparse one? 回答1: The dense hashtable is your ordinary textbook hashtable implementation. The sparse hashtable stores only the elements that have actually been set, divided over a number of arrays. To quote from the comments in the implementation of sparse tables: // 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 //

What is the main implementation idea behind sparse hash table?

我们两清 提交于 2019-12-03 10:55:41
Why does Google sparsehash open-source library has two implementations: a dense hashtable and a sparse one? The dense hashtable is your ordinary textbook hashtable implementation. The sparse hashtable stores only the elements that have actually been set, divided over a number of arrays. To quote from the comments in the implementation of sparse tables: // 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