public ValueCollection(FastDictionary <TKey, TValue, TComparer> dictionary) { Contract.Requires(dictionary != null); Contract.EndContractBlock(); this.dictionary = dictionary; }
public FastDictionary( int initialBucketCount, FastDictionary <TKey, TValue, TComparer> src) { Contract.Requires(src != null); Contract.Ensures(this.Capacity >= initialBucketCount); Contract.Ensures(this.Capacity >= src.Capacity); Contract.EndContractBlock(); this.initialCapacity = DictionaryHelper.NextPowerOf2(initialBucketCount); this.Capacity = Math.Max(src.Capacity, initialBucketCount); this.Count = src.Count; this.numberOfUsed = src.numberOfUsed; this.numberOfDeleted = src.numberOfDeleted; this.nextGrowthThreshold = src.nextGrowthThreshold; var newCapacity = this.Capacity; if (ReferenceEquals(this.Comparer, src.Comparer)) { // Initialization through copy (very efficient) because the comparer is the same. this.entries = new Entry[newCapacity]; Array.Copy(src.entries, this.entries, newCapacity); } else { // Initialization through rehashing because the comparer is not the same. var e = new Entry[newCapacity]; BlockCopyMemoryHelper.Memset(e, new Entry(UnusedHash, default(TKey), default(TValue))); // Creating a temporary alias to use for rehashing. this.entries = src.entries; // This call will rewrite the aliases this.Rehash(e); } }
internal ValueEnumerator(FastDictionary <TKey, TValue, TComparer> dictionary) { this.dictionary = dictionary; this.index = 0; this.Current = default(TValue); }
public FastDictionary(FastDictionary <TKey, TValue, TComparer> src) : this(src.Capacity, src) { }
internal Enumerator(FastDictionary <TKey, TValue, TComparer> dictionary) { this.dictionary = dictionary; this.index = 0; this.Current = new KeyValuePair <TKey, TValue>(); }