Files
stgsharp/源代码/StgSharp/Logic/Collections/IBidrirectionalDictionary.cs
T

50 lines
2.0 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace StgSharp.Collections
{
public interface IBidirectionalDictionary<TFirst, TSecond> :
IDictionary<TFirst, TSecond>
{
#pragma warning disable CA1033
ICollection<TFirst> IDictionary<TFirst, TSecond>.Keys => FirstIndex;
ICollection<TSecond> IDictionary<TFirst, TSecond>.Values => SecondIndex;
bool IDictionary<TFirst, TSecond>.ContainsKey(TFirst key) => Contains(key);
#pragma warning restore CA1033
public IReadOnlyDictionary<TFirst, TSecond> Forward { get; }
public IReadOnlyDictionary<TSecond, TFirst> Reverse { get; }
public ICollection<TFirst> FirstIndex { get;}
public ICollection<TSecond> SecondIndex { get; }
public TFirst this[TSecond key] { get;set; }
/// <summary>
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains the
/// specified key.
/// </summary>
/// <param name="key"> The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />. </param>
/// <returns>
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains an element with the
/// specified key; otherwise, false.
/// </returns>
public bool Contains(TSecond key);
/// <summary>
/// Determines whether the <see cref="IBidirectionalDictionary{TFirst, TSecond}" /> contains the
/// specified key.
/// </summary>
/// <param name="key"> The value to locate in the <see cref="IBidirectionalDictionary{TFirst, TSecond}" />. </param>
/// <returns>
/// true if the <see cref="IBidirectionalDictionary{TFirst, TSecond}"/> contains an element with the
/// specified key; otherwise, false.
/// </returns>
public bool Contains(TFirst key);
public bool TryGetValue(TSecond key, out TFirst value);
}
}