/// <summary> /// Add a key / value pair to the dictionary. /// </summary> /// <param name="item"> /// The <see cref="KeyValuePair{TKey, TValue}"/> to add. /// </param> public void Add(KeyValuePair <T3, T4> item) { if (item.Key == null) { throw new ArgumentException("Key cannot be null.", nameof(item)); } if (item.Value == null) { throw new ArgumentException("Value cannot be null.", nameof(item)); } if (ForwardLookup.ContainsKey(item.Key)) { throw new ArgumentException("The dictionary's forward-lookup section already contains the specified key.", nameof(item)); } if (ReverseLookup.ContainsKey(item.Value)) { throw new ArgumentException("The dictionary's reverse-lookup section already contains the specified key.", nameof(item)); } ForwardLookup.Add(item.Key, item.Value); ReverseLookup.Add(item.Value, item.Key); }
/// <summary> /// Add a value to the dictionary with the specified key. /// </summary> /// <param name="key"> /// The key. /// </param> /// <param name="value"> /// The value. /// </param> public void Add(T3 key, T4 value) { if (key == null) { throw new ArgumentNullException(nameof(key)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } if (ForwardLookup.ContainsKey(key)) { throw new ArgumentException("The dictionary's forward-lookup section already contains the specified key.", nameof(key)); } if (ReverseLookup.ContainsKey(value)) { throw new ArgumentException("The dictionary's reverse-lookup section already contains the specified key.", nameof(value)); } ForwardLookup.Add(key, value); ReverseLookup.Add(value, key); }
/// <summary> /// Determine whether the dictionary contains the specified key. /// </summary> /// <param name="key"> /// The key. /// </param> /// <returns> /// <c>true</c>, if the dictionary contains the key; otherwise, <c>false</c>. /// </returns> public bool ContainsKey(T3 key) => ForwardLookup.ContainsKey(key);