From bb7bc43357b9162832d066bc39ec2ba0dde159ce Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 14 Apr 2020 16:54:26 +0200 Subject: [PATCH] Added the IDictionary interface --- .../DictionarySlim{TKey,TValue}.cs | 4 ++-- .../IDictionary{TKey}.cs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/IDictionary{TKey}.cs diff --git a/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs b/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs index c9acfd2a..2c1862ac 100644 --- a/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs +++ b/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/DictionarySlim{TKey,TValue}.cs @@ -29,7 +29,7 @@ namespace Microsoft.Collections.Extensions /// 3) This means it can avoid storing a comparer, and avoid the likely virtual call to a comparer. /// [DebuggerDisplay("Count = {Count}")] - internal sealed class DictionarySlim + internal sealed class DictionarySlim : IDictionary where TKey : struct, IEquatable { // See info in CoreFX labs for how this works @@ -71,7 +71,7 @@ namespace Microsoft.Collections.Extensions _entries = InitialEntries; } - /// + /// public bool Remove(TKey key) { Entry[] entries = _entries; diff --git a/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/IDictionary{TKey}.cs b/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/IDictionary{TKey}.cs new file mode 100644 index 00000000..e4976feb --- /dev/null +++ b/Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions/IDictionary{TKey}.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace Microsoft.Collections.Extensions +{ + /// + /// An interface providing value-invariant access to a instance. + /// + /// The type of keys in the dictionary. + internal interface IDictionary + where TKey : struct, IEquatable + { + /// + bool Remove(TKey key); + } +}