1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-04-10 11:15:45 +02:00

Added the IDictionary<in TKey> interface

This commit is contained in:
Sergio Pedri 2020-04-14 16:54:26 +02:00
parent 32e006b993
commit bb7bc43357
2 changed files with 18 additions and 2 deletions
Microsoft.Toolkit.Mvvm/Microsoft.Collections.Extensions

View File

@ -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.
/// </remarks>
[DebuggerDisplay("Count = {Count}")]
internal sealed class DictionarySlim<TKey, TValue>
internal sealed class DictionarySlim<TKey, TValue> : IDictionary<TKey>
where TKey : struct, IEquatable<TKey>
{
// See info in CoreFX labs for how this works
@ -71,7 +71,7 @@ public void Clear()
_entries = InitialEntries;
}
/// <inheritdoc cref="Dictionary{TKey,TValue}.Remove"/>
/// <inheritdoc/>
public bool Remove(TKey key)
{
Entry[] entries = _entries;

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
namespace Microsoft.Collections.Extensions
{
/// <summary>
/// An interface providing value-invariant access to a <see cref="DictionarySlim{TKey,TValue}"/> instance.
/// </summary>
/// <typeparam name="TKey">The type of keys in the dictionary.</typeparam>
internal interface IDictionary<in TKey>
where TKey : struct, IEquatable<TKey>
{
/// <inheritdoc cref="Dictionary{TKey,TValue}.Remove"/>
bool Remove(TKey key);
}
}