Пример #1
0
        private BaseImmutableDictionary <TKey, TValue> CopyAndMutate(Action <Dictionary <TKey, TValue> > mutator)
        {
            BaseImmutableDictionary <TKey, TValue> dictionary = new BaseImmutableDictionary <TKey, TValue>();

            foreach (KeyValuePair <TKey, TValue> pair in _dictionary)
            {
                dictionary._dictionary.Add(pair.Key, pair.Value);
            }
            mutator(dictionary._dictionary);

            return(dictionary);
        }
 /// <summary>
 /// Creates a dictionary with the specified initial capacity.
 /// </summary>
 /// <param name="capacity">the starting capacity of the dictionary</param>
 public ImmutableDictionary(int capacity)
 {
     _headDictionary = new BaseImmutableDictionary <TKey, TValue>(capacity);
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 public ImmutableDictionary()
 {
     _headDictionary = new BaseImmutableDictionary <TKey, TValue>();
 }