public TValue this[TKey key] { get { TValue res; if (TryGetValue(key, out res)) { return(res); } throw new KeyNotFoundException(); } set { IEqualityComparer <TKey> comparer = null; if (_data == null || (comparer = _data as IEqualityComparer <TKey>) != null) { _data = new SingleDependency(key, value, comparer ?? EqualityComparer <TKey> .Default); return; } var single = _data as SingleDependency; if (single != null) { if (single.Comparer.Equals(single.Key, key)) { single.Value = value; return; } var data = new AnalysisDictionary <TKey, TValue>(single.Comparer); data[single.Key] = single.Value; data[key] = value; _data = data; return; } var dict = _data as AnalysisDictionary <TKey, TValue>; if (dict == null) { _data = dict = new AnalysisDictionary <TKey, TValue>(comparer ?? EqualityComparer <TKey> .Default); } dict[key] = value; } }
internal AnalysisDictionaryEnumerator(AnalysisDictionary <TKey, TValue> dict) { _buckets = dict._buckets; _curValue = default(KeyValuePair <TKey, TValue>); _curBucket = 0; }