简体   繁体   English

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

[英]Why so many null references in Hashtable

在此处输入图片说明

I was trying to debug the Hashtable contents and got curious why there are so many Null references init. 我试图调试Hashtable的内容,并且好奇为什么初始化中有这么多的Null引用。

This is just how Hash tables work. 这就是哈希表的工作方式。 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. 哈希表使用哈希函数来计算存储桶或插槽数组的索引,从中可以找到所需的值。

There are normally more buckets than values, that's why some buckets are empty. 通常,存储桶多于值,这就是为什么一些存储桶为空的原因。

This is important for performance of the hash table. 这对于哈希表的性能很重要。

A critical statistic for a hash table is the load factor, defined as 哈希表的关键统计数据是负载因子,定义为

load_factor=n/k load_factor = N / K

where n is the number of entries occupied in the hash table. 其中,n是哈希表中占用的条目数。 k is the number of buckets. k是存储桶数。 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. 对于固定数量的存储桶,查找时间随条目数量而增加,因此无法实现所需的恒定时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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