java中哈希表桶的大小是多少?

时间:2022-10-13 16:48:55

We know that more than one object with same hash code can be stored in a single bucket of a hash-table in JAVA. My question is:

我们知道,具有相同哈希码的多个对象可以存储在JAVA中的哈希表的单个桶中。我的问题是:

What is maximum number of objects a single bucket can store?

单个存储桶可以存储的最大对象数是多少?

1 个解决方案

#1


3  

It's unlimited. Whatever has the same hashCode (with the mask) goes into the same position in the hash table. It's basically linked list.

它是无限的。无论具有相同的hashCode(使用掩码)进入哈希表中的相同位置。它基本上是链表。

It may cause some problems obviously as it could significantly affect the performance but usually with reasonable distribution of items it hardly happens that there are more than one or two items in single position.

它可能会引起一些明显的问题,因为它可能会对性能产生很大影响,但通常情况下合理分配物品时,单个位置的物品数量不会超过一个或两个。

#1


3  

It's unlimited. Whatever has the same hashCode (with the mask) goes into the same position in the hash table. It's basically linked list.

它是无限的。无论具有相同的hashCode(使用掩码)进入哈希表中的相同位置。它基本上是链表。

It may cause some problems obviously as it could significantly affect the performance but usually with reasonable distribution of items it hardly happens that there are more than one or two items in single position.

它可能会引起一些明显的问题,因为它可能会对性能产生很大影响,但通常情况下合理分配物品时,单个位置的物品数量不会超过一个或两个。