Class TwoWayDictionary<TKey, TValue>
- Namespace
- SunamoTwoWayDictionary
- Assembly
- SunamoTwoWayDictionary.dll
A dictionary that maintains bidirectional mapping between keys and values, allowing lookup in both directions.
public class TwoWayDictionary<TKey, TValue> where TKey : notnull where TValue : notnull
Type Parameters
TKeyThe type of the forward key.
TValueThe type of the forward value.
- Inheritance
-
TwoWayDictionary<TKey, TValue>
- Inherited Members
- Extension Methods
Constructors
TwoWayDictionary()
Initializes a new instance of the TwoWayDictionary<TKey, TValue> class.
public TwoWayDictionary()
TwoWayDictionary(int)
Initializes a new instance of the TwoWayDictionary<TKey, TValue> class with specified capacity.
public TwoWayDictionary(int capacity)
Parameters
capacityintThe initial capacity of both dictionaries.
Properties
ForwardDictionary
Gets or sets the forward dictionary mapping keys to values.
public Dictionary<TKey, TValue> ForwardDictionary { get; set; }
Property Value
- Dictionary<TKey, TValue>
ReverseDictionary
Gets or sets the reverse dictionary mapping values to keys.
public Dictionary<TValue, TKey> ReverseDictionary { get; set; }
Property Value
- Dictionary<TValue, TKey>
Methods
Add(TKey, TValue)
Adds a key-value pair to both the forward and reverse dictionaries.
public void Add(TKey key, TValue value)
Parameters
keyTKeyThe key for the forward dictionary.
valueTValueThe value for the forward dictionary, which becomes the key in the reverse dictionary.