public FastDictionary(int initialBucketCount, FastDictionary <TKey, TValue> src, IEqualityComparer <TKey> comparer) { Contract.Requires(src != null); Contract.Ensures(_capacity >= initialBucketCount); Contract.Ensures(_capacity >= src._capacity); this.comparer = comparer ?? EqualityComparer <TKey> .Default; this._initialCapacity = DictionaryHelper.NextPowerOf2(initialBucketCount); this._capacity = Math.Max(src._capacity, initialBucketCount); this._size = src._size; this._numberOfUsed = src._numberOfUsed; this._numberOfDeleted = src._numberOfDeleted; this._nextGrowthThreshold = src._nextGrowthThreshold; int newCapacity = _capacity; if (comparer == src.comparer) { // Initialization through copy (very efficient) because the comparer is the same. this._entries = new Entry[newCapacity]; Array.Copy(src._entries, _entries, newCapacity); } else { // Initialization through rehashing because the comparer is not the same. var entries = new Entry[newCapacity]; BlockCopyMemoryHelper.Memset(entries, new Entry(kUnusedHash, default(TKey), default(TValue))); // Creating a temporary alias to use for rehashing. this._entries = src._entries; // This call will rewrite the aliases Rehash(entries); } }
public ValueCollection(FastDictionary <TKey, TValue> dictionary) { Contract.Requires(dictionary != null); this.dictionary = dictionary; }
internal Enumerator(FastDictionary <TKey, TValue> dictionary) { this.dictionary = dictionary; index = 0; currentKey = default(TKey); }
internal Enumerator(FastDictionary <TKey, TValue> dictionary) { this.dictionary = dictionary; this.index = 0; this.current = new KeyValuePair <TKey, TValue>(); }
public FastDictionary(FastDictionary <TKey, TValue> src) : this(src._capacity, src, src.comparer) { }
public FastDictionary(FastDictionary <TKey, TValue> src, IEqualityComparer <TKey> comparer) : this(src._capacity, src, comparer) { }