What is the intended usage of the ImmutableDictionary<TKey,TValue>.ValueComparer property?
Why is it useful being able to compare dictionary values by using a specified equality semantic?
I totally understand the necessity of being able to compare dictionary keys by using a specified equality semantic, but I can't get the point for value comparison. Why the immutable dictionary creator should be able to specify the intended semantic for value comparison ? Can you please show me a use case where it is useful ?
Interestingly enough, by checking at the Microsoft documentation, it seems that the Dictionary<TKey, TValue>
class does not have a similar property. The only available comparer on the Dictionary<TKey, TValue>
class is the one meant to compare the keys.
I'm totally sure that the public API of the ImmutableDictionary<TKey,TValue>
class has been carefully designed, so I would like to understand what I'm missing about the need for value comparison in a dictionary.
SetItem
method.SetItem
method in the public API of theDictionary<TKey, TValue>
class, so in that case give the caller the possibility to customize the value comparison semantic is far less relevant.