Table of Contents

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

TKey

The type of the forward key.

TValue

The 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

capacity int

The 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

key TKey

The key for the forward dictionary.

value TValue

The value for the forward dictionary, which becomes the key in the reverse dictionary.