为什么哈希表中有这么多空引用

Why so many null references in Hashtable

我正在尝试调试 Hashtable 内容并且很好奇为什么有这么多 Null 引用 init。

这就是哈希 table 的工作原理。 For reference

In computing, a hash table (hash map) is a data structure which implements an associative array abstract data type, a structure that can map keys to values. A hash table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.

桶的数量通常多于值,这就是为什么有些桶是空的。

这对哈希的性能很重要 table。

A critical statistic for a hash table is the load factor, defined as

load_factor=n/k

where n is the number of entries occupied in the hash table. k is the number of buckets. As the load factor grows larger, the hash table becomes slower, and it may even fail to work (depending on the method used). The expected constant time property of a hash table assumes that the load factor is kept below some bound. For a fixed number of buckets, the time for a lookup grows with the number of entries and therefore the desired constant time is not achieved.