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

Method Add

sdks/csharp/src/MultiDictionary.cs:67–86  ·  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). Whether the key is entirely new to the dictionary. If it was already present, we assert that the old value is equal to the new value.

(TKey key, TValue value)

Source from the content-addressed store, hash-verified

65 /// <param name="item"></param>
66 /// <returns>Whether the key is entirely new to the dictionary. If it was already present, we assert that the old value is equal to the new value.</returns>
67 public bool Add(TKey key, TValue value)
68 {
69 if (value == null)
70 {
71 throw new NullReferenceException("Null values are forbidden in multidictionary");
72 }
73 Debug.Assert(RawDict != null);
74 Debug.Assert(key != null);
75 if (RawDict.TryGetValue(key, out var result))
76 {
77 Debug.Assert(ValueComparer.Equals(value, result.Value));
78 RawDict[key] = (value, result.Multiplicity + 1);
79 return false;
80 }
81 else
82 {
83 RawDict[key] = (value, 1);
84 return true;
85 }
86 }
87
88 /// <summary>
89 /// Completely clear the multidictionary.

Callers 15

ParseMessagesMethod · 0.45
OnMessageReceivedMethod · 0.45
GetMinMaxTimesMethod · 0.45
AddTableMethod · 0.45
UniqueIndexBaseMethod · 0.45
BTreeIndexBaseMethod · 0.45
ParseInsertOnlyMethod · 0.45
ParseMethod · 0.45
ApplyMethod · 0.45
AddListenerMethod · 0.45
AddListenerMethod · 0.45
SaveTokenMethod · 0.45

Calls 2

AssertMethod · 0.80
EqualsMethod · 0.45

Tested by

no test coverage detected