private void GetHashAndBucket(TKey key, out uint hash, out DictionaryBucket <TKey, TValue> bucket, bool returnNullForEmptyBucket = false) { EnsureBucketsExist(); hash = key.GetBinaryHashCode32(); int bucketIndex = (int)(hash % NumBuckets); bucket = returnNullForEmptyBucket ? GetBucketAtIndexIfExists(bucketIndex) : GetBucketAtIndex(bucketIndex); }
private DictionaryBucket <TKey, TValue> GetBucketAtIndex(int index, LazinatorList <DictionaryBucket <TKey, TValue> > buckets = null) { if (buckets == null) { buckets = Buckets; } var bucket = buckets[index]; if (bucket == null) { bucket = new DictionaryBucket <TKey, TValue>(); buckets[index] = bucket; } return(bucket); }
private void GetHashAndBucket(TKey key, LazinatorList <DictionaryBucket <TKey, TValue> > buckets, out uint hash, out DictionaryBucket <TKey, TValue> bucket) { // This method is for use when using a replacement set of buckets. EnsureBucketsExist(); hash = key.GetBinaryHashCode32(); int bucketIndex = (int)(hash % buckets.Count); bucket = GetBucketAtIndex(bucketIndex, buckets); }