Class DoubleIndexedDictionary<T1, T2>
- Namespace
- Utils.Collections
- Assembly
- Utils.dll
Represents a dictionary that maintains two-way mappings between keys of type T1
and values of type T2. This allows bidirectional access by both key and value.
public class DoubleIndexedDictionary<T1, T2> : IReadOnlyCollection<KeyValuePair<T1, T2>>, IEnumerable<KeyValuePair<T1, T2>>, IEnumerable where T1 : notnull where T2 : notnull
Type Parameters
T1The type of the first key.
T2The type of the second key.
- Inheritance
-
DoubleIndexedDictionary<T1, T2>
- Implements
-
IReadOnlyCollection<KeyValuePair<T1, T2>>IEnumerable<KeyValuePair<T1, T2>>
- Inherited Members
- Extension Methods
Constructors
DoubleIndexedDictionary()
Initializes a new instance of the DoubleIndexedDictionary<T1, T2> class.
public DoubleIndexedDictionary()
DoubleIndexedDictionary(IEnumerable<KeyValuePair<T1, T2>>)
Initializes a new instance of the DoubleIndexedDictionary<T1, T2> class with predefined key-value pairs.
public DoubleIndexedDictionary(IEnumerable<KeyValuePair<T1, T2>> values)
Parameters
valuesIEnumerable<KeyValuePair<T1, T2>>A collection of key-value pairs.
DoubleIndexedDictionary(IEnumerable<(T1 Key, T2 Value)>)
Initializes a new instance of the DoubleIndexedDictionary<T1, T2> class with predefined key-value pairs.
public DoubleIndexedDictionary(IEnumerable<(T1 Key, T2 Value)> values)
Parameters
valuesIEnumerable<(T1 Key, T2 Value)>A collection of (T1 key, T2 value) pairs.
DoubleIndexedDictionary(IEnumerable<(T2 Value, T1 Key)>)
Initializes a new instance of the DoubleIndexedDictionary<T1, T2> class with predefined key-value pairs.
public DoubleIndexedDictionary(IEnumerable<(T2 Value, T1 Key)> values)
Parameters
valuesIEnumerable<(T2 Value, T1 Key)>A collection of (T2 value, T1 key) pairs.
Properties
Count
Gets the number of elements contained in the dictionary.
public int Count { get; }
Property Value
Left
Accessor to interact with the dictionary using T1 as the key.
public IDictionary<T1, T2> Left { get; }
Property Value
- IDictionary<T1, T2>
Right
Accessor to interact with the dictionary using T2 as the key.
public IDictionary<T2, T1> Right { get; }
Property Value
- IDictionary<T2, T1>
Methods
Add(KeyValuePair<T1, T2>)
Adds a key-value pair to the dictionary.
public void Add(KeyValuePair<T1, T2> item)
Parameters
itemKeyValuePair<T1, T2>
Add(T1, T2)
Adds a key-value pair to the dictionary.
public void Add(T1 key, T2 value)
Parameters
keyT1valueT2
Clear()
Clears all entries from the dictionary.
public void Clear()
GetEnumerator()
Returns an enumerator that iterates through the dictionary.
public IEnumerator<KeyValuePair<T1, T2>> GetEnumerator()
Returns
- IEnumerator<KeyValuePair<T1, T2>>
Remove(KeyValuePair<T1, T2>)
Removes a specific key-value pair from the dictionary.
public bool Remove(KeyValuePair<T1, T2> item)
Parameters
itemKeyValuePair<T1, T2>