Add a key-value-pair to the multidictionary. If the key is already present, its associated value must satisfy keyComparer.Equals(value, item.Value).
(TKey key, TValue value)
| 637 | /// </summary> |
| 638 | /// <param name="item"></param> |
| 639 | public void Add(TKey key, TValue value) |
| 640 | { |
| 641 | if (value == null) |
| 642 | { |
| 643 | throw new NullReferenceException("Null values are forbidden in multidictionary"); |
| 644 | } |
| 645 | Debug.Assert(RawDict != null); |
| 646 | Debug.Assert(key != null); |
| 647 | KeyDelta result; |
| 648 | if (RawDict.TryGetValue(key, out result)) |
| 649 | { |
| 650 | result.Add(value, ValueComparer); |
| 651 | } |
| 652 | else |
| 653 | { |
| 654 | result = new(new(value, +1)); |
| 655 | } |
| 656 | RawDict[key] = result; |
| 657 | } |
| 658 | |
| 659 | /// <summary> |
| 660 | /// Completely clear the multidictionary. |