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
@@ -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 @@ namespace Microsoft.Collections.Extensions
_entries = InitialEntries;
}
/// <inheritdoc cref="Dictionary{TKey,TValue}.Remove"/>
/// <inheritdoc/>
public bool Remove(TKey key)
{
Entry[] entries = _entries;
@@ -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);
}
}