GrowTableメソッドでいくつかの魔法を説明できますか?.Netの同時辞書でGrowTableメソッド
コード:他の.NETのコレクション(リスト、辞書)メソッドは、ダブルサイズを維持リサイズして
// Compute the new table size. We find the smallest integer larger than twice the previous table size, and not divisible by
// 2,3,5 or 7. We can consider a different table-sizing policy in the future.
int newLength;
try
{
checked
{
// Double the size of the buckets table and add one, so that we have an odd integer.
newLength = buckets.Length * 2 + 1;
// Now, we only need to check odd integers, and find the first that is not divisible
// by 3, 5 or 7.
while (newLength % 3 == 0 || newLength % 5 == 0 || newLength % 7 == 0)
{
newLength += 2;
}
Assert(newLength % 2 != 0);
}
}
。
'Dictionary'は倍精度のサイズを維持しません。事前計算テーブルの素数を使用します。 – svick
はい、そうです。ありがとう。しかし、私は理解していない、なぜバケットリンクのサイズはエントリのサイズと等しい?バケットリンクはエントリより小さくする必要があります... –