MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / Add

Method Add

sdks/csharp/src/MultiDictionary.cs:639–657  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 2

AssertMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected