protected DictionaryImpl(int capacity, DictionaryImpl <TKey, TKeyStore, TValue> other) { capacity = Util.AlignToPowerOfTwo(capacity); this._entries = new Entry[capacity]; this._size = other._size; this._topDict = other._topDict; this._keyComparer = other._keyComparer; }
public Snapshot(DictionaryImpl <TKey, TKeyStore, TValue> dict) { this._table = dict; // linearization point. // if table is quiescent and has no copy in progress, // we can simply iterate over its table. while (true) { if (_table._newTable == null) { break; } // there is a copy in progress, finish it and try again _table.HelpCopyImpl(copy_all: true); this._table = (DictionaryImpl <TKey, TKeyStore, TValue>)(this._table._topDict._table); } // Warm-up the iterator MoveNext(); }
private ConcurrentDictionary( int capacity, IEqualityComparer <TKey> comparer = null) { if (capacity < 0) { throw new ArgumentOutOfRangeException(nameof(capacity)); } if (default(TKey) == null) { if (typeof(TKey) == typeof(ValueType) || !(default(TKey) is ValueType)) { _table = DictionaryImpl <TKey, TValue> .CreateRefUnsafe(this, capacity); _table._keyComparer = comparer ?? EqualityComparer <TKey> .Default; return; } } else { if (typeof(TKey) == typeof(int)) { if (comparer == null) { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplIntNoComparer <TValue>(capacity, (ConcurrentDictionary <int, TValue>)(object) this); } else { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplInt <TValue>(capacity, (ConcurrentDictionary <int, TValue>)(object) this); _table._keyComparer = comparer; } return; } if (typeof(TKey) == typeof(long)) { if (comparer == null) { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplLongNoComparer <TValue>(capacity, (ConcurrentDictionary <long, TValue>)(object) this); } else { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplLong <TValue>(capacity, (ConcurrentDictionary <long, TValue>)(object) this); _table._keyComparer = comparer; } return; } if (typeof(TKey) == typeof(uint)) { if (comparer == null) { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplUIntNoComparer <TValue>(capacity, (ConcurrentDictionary <uint, TValue>)(object) this); } else { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplUInt <TValue>(capacity, (ConcurrentDictionary <uint, TValue>)(object) this); _table._keyComparer = comparer; } return; } if (typeof(TKey) == typeof(ulong)) { if (comparer == null) { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplULongNoComparer <TValue>(capacity, (ConcurrentDictionary <ulong, TValue>)(object) this); } else { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplULong <TValue>(capacity, (ConcurrentDictionary <ulong, TValue>)(object) this); _table._keyComparer = comparer; } return; } if (typeof(TKey) == typeof(IntPtr)) { if (comparer == null) { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplIntPtrNoComparer <TValue>(capacity, (ConcurrentDictionary <IntPtr, TValue>)(object) this); } else { _table = (DictionaryImpl <TKey, TValue>)(object) new DictionaryImplIntPtr <TValue>(capacity, (ConcurrentDictionary <IntPtr, TValue>)(object) this); _table._keyComparer = comparer; } return; } } _table = new DictionaryImplBoxed <TKey, TValue>(capacity, this); _table._keyComparer = comparer ?? EqualityComparer <TKey> .Default; }
public SnapshotIDict(DictionaryImpl <TKey, TKeyStore, TValue> dict) : base(dict) { }
public static void TryRearm(DictionaryImpl <TKey, TKeyStore, TValue> dict) { ref var sweeperLocation = ref dict._topDict._sweeperInstance;