mirror of
https://github.com/TalAloni/SMBLibrary.git
synced 2025-05-28 16:29:51 +02:00
SMBServer v1.0.5
This commit is contained in:
parent
b75820452d
commit
bd1006cb81
400 changed files with 28062 additions and 0 deletions
51
Utilities/Generics/Map.cs
Normal file
51
Utilities/Generics/Map.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
/// <summary>
|
||||
/// Based on:
|
||||
/// http://stackoverflow.com/questions/10966331/two-way-bidirectional-dictionary-in-c
|
||||
/// </summary>
|
||||
public class Map<T1, T2>
|
||||
{
|
||||
private Dictionary<T1, T2> m_forward = new Dictionary<T1, T2>();
|
||||
private Dictionary<T2, T1> m_reverse = new Dictionary<T2, T1>();
|
||||
|
||||
public Map()
|
||||
{
|
||||
m_forward = new Dictionary<T1, T2>();
|
||||
m_reverse = new Dictionary<T2, T1>();
|
||||
}
|
||||
|
||||
public void Add(T1 key, T2 value)
|
||||
{
|
||||
m_forward.Add(key, value);
|
||||
m_reverse.Add(value, key);
|
||||
}
|
||||
|
||||
public bool ContainsKey(T1 key)
|
||||
{
|
||||
return m_forward.ContainsKey(key);
|
||||
}
|
||||
|
||||
public bool ContainsValue(T2 value)
|
||||
{
|
||||
return m_reverse.ContainsKey(value);
|
||||
}
|
||||
|
||||
public T2 this[T1 key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_forward[key];
|
||||
}
|
||||
}
|
||||
|
||||
public T1 GetKey(T2 value)
|
||||
{
|
||||
return m_reverse[value];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue