This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Related: https://github.com/dotnet/runtime/issues/101003 -- [API Proposal]: New method HashSet<T>.Add that replaces an existing element if found | |
abstract class JsonKeyedCollectionBase<TKey, TItem> : ICollection<TItem>, IEqualityComparer<TItem> | |
{ | |
private readonly HashSet<TItem> _set; | |
protected abstract TKey GetKeyForItem(TItem item); | |
protected abstract TItem GetItemForKey(TKey key); | |
protected virtual IEqualityComparer<TKey> KeyComparer => EqualityComparer<TKey>.Default; | |
protected virtual IComparer<TItem> EnumerationComparer => null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/questions/60695167/concurrentdictionary-with-multiple-values-per-key-removing-empty-entries | |
// Alternative implementation | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Collections.Concurrent; | |
using System.Collections.Immutable; | |
using System.Linq; | |
public class ConcurrentMultiDictionary<TKey, TValue> | |
: IEnumerable<KeyValuePair<TKey, TValue[]>> |
OlderNewer