Class Map<T1, T2>
Two-way dictionary.
public class Map<T1, T2> : IDictionary<T1, T2>, ICollection<KeyValuePair<T1, T2>>, IEnumerable<KeyValuePair<T1, T2>>, IEnumerable
Type Parameters
T1T2
- Inheritance
-
Map<T1, T2>
- Implements
-
IDictionary<T1, T2>ICollection<KeyValuePair<T1, T2>>IEnumerable<KeyValuePair<T1, T2>>
- Inherited Members
- Extension Methods
Constructors
Map()
public Map()
Map(int)
public Map(int capacity)
Parameters
capacityint
Map(int, IEqualityComparer<T1>?)
public Map(int capacity, IEqualityComparer<T1>? comparer1)
Parameters
capacityintcomparer1IEqualityComparer<T1>
Map(int, IEqualityComparer<T1>?, IEqualityComparer<T2>?)
public Map(int capacity, IEqualityComparer<T1>? comparer1, IEqualityComparer<T2>? comparer2)
Parameters
capacityintcomparer1IEqualityComparer<T1>comparer2IEqualityComparer<T2>
Map(int, IEqualityComparer<T2>?)
public Map(int capacity, IEqualityComparer<T2>? comparer2)
Parameters
capacityintcomparer2IEqualityComparer<T2>
Properties
Count
Gets the number of elements contained in the ICollection<T>.
public int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
this[T1]
Gets or sets the element with the specified key.
public T2 this[T1 key] { get; set; }
Parameters
keyT1The key of the element to get or set.
Property Value
- T2
The element with the specified key.
Exceptions
- ArgumentNullException
keyis null.- KeyNotFoundException
The property is retrieved and
keyis not found.- NotSupportedException
The property is set and the IDictionary<TKey, TValue> is read-only.
this[T2]
public T1 this[T2 key] { get; set; }
Parameters
keyT2
Property Value
- T1
Methods
Add(T1, T2)
public void Add(T1 item1, T2 item2)
Parameters
item1T1item2T2
Exceptions
- ArgumentException
Either key is already in the map.
Clear()
Removes all items from the ICollection<T>.
public void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Contains(T1)
public bool Contains(T1 key)
Parameters
keyT1
Returns
Contains(T1, T2)
public bool Contains(T1 item1, T2 item2)
Parameters
item1T1item2T2
Returns
Contains(T2)
public bool Contains(T2 key)
Parameters
keyT2
Returns
ContainsT1(T1)
public bool ContainsT1(T1 key)
Parameters
keyT1
Returns
ContainsT2(T2)
public bool ContainsT2(T2 key)
Parameters
keyT2
Returns
Remove(T1)
public bool Remove(T1 key)
Parameters
keyT1
Returns
Remove(T2)
public bool Remove(T2 key)
Parameters
keyT2
Returns
RemoveT1(T1)
public bool RemoveT1(T1 key)
Parameters
keyT1
Returns
RemoveT2(T2)
public bool RemoveT2(T2 key)
Parameters
keyT2
Returns
SetOrAdd(T1, T2)
public void SetOrAdd(T1 item1, T2 item2)
Parameters
item1T1item2T2
TryGetValue(T1, out T2)
public bool TryGetValue(T1 key, out T2 value)
Parameters
keyT1valueT2
Returns
TryGetValue(T2, out T1)
public bool TryGetValue(T2 key, out T1 value)
Parameters
keyT2valueT1
Returns
TryGetValueT1(T1, out T2)
public bool TryGetValueT1(T1 key, out T2 value)
Parameters
keyT1valueT2
Returns
TryGetValueT2(T2, out T1)
public bool TryGetValueT2(T2 key, out T1 value)
Parameters
keyT2valueT1